This component holds a collection of panels and shows the selected panel. A typical use of a Coral.PanelStack would be controlling content in a Coral.TabView or a Coral.WizardView. See the documentation for those other components for a working example.

Markup Examples

|

Preselected Item

Panel 1: This is the content of Panel 1. There are more Panels defined in the PanelStack !
Show Markup
<coral-panelstack class="coral-Well" id="panelListPreselectedItem">
  <coral-panel>Panel 0: This is the content of Panel 1</coral-panel>
  <coral-panel selected>Panel 1: This is the content of Panel 1. There are more Panels defined in the PanelStack !</coral-panel>
  <coral-panel>Panel 2: This is the content of Panel 2</coral-panel>
  <coral-panel>Panel 3: This is the content of Panel 3. You need JavaScript to interact with this component</coral-panel>
  <coral-panel>Panel 4: This is the content of Panel 4</coral-panel>
</coral-panelstack>

None selected

Nothing is shown, if nothing is selected

Show Markup
<coral-panelstack class="coral-Well" id="panelListNoneSelected">
  <coral-panel>Panel 0: This is the content of Panel 1</coral-panel>
  <coral-panel>Panel 1: This is the content of Panel 1. There are more Panels defined in the PanelStack !</coral-panel>
  <coral-panel>Panel 2: This is the content of Panel 2</coral-panel>
  <coral-panel>Panel 3: This is the content of Panel 3. You need JavaScript to interact with this component</coral-panel>
  <coral-panel>Panel 4: This is the content of Panel 4</coral-panel>
</coral-panelstack>

Programmatic Interaction

The following shows how to interaction with the selecteditem in the PanelStack component. Below is a PanelStack that applies the coral-Well style to its items. Neat, isn't it?

Panel 0: I am Panel 0.

Selected Index: 0

Show Markup
<coral-panelstack id="select_rotation_example">
  <coral-panel selected class="coral-Well">
    Panel 0: I am Panel 0.
  </coral-panel>
  <coral-panel class="coral-Well">
    Panel 1: Haha, Panel 1 here.
  </coral-panel>
  <coral-panel class="coral-Well">
    Panel 2: Wait for it ! Panel 3 comes next.
  </coral-panel>
  <coral-panel class="coral-Well">
    Panel 3: I will not go away, only if you click on "Cycle"
  </coral-panel>
  <coral-panel class="coral-Well">
    Panel 4: Last, but not least.
  </coral-panel>
</coral-panelstack>
<h4 id='selectedIndexLabel'>Selected Index: 0</h4>

Click this cycle button to interact with the PanelStack

The following JavaScript shows how to set the selected attribute

<script>
$(document).ready(function()
{
  var panelList = document.querySelector('#select_rotation_example');
  $('#cycleActive').on('click', function()
  {
    var next = $(panelList.selectedItem).nextAll('coral-panel').first();
  
    if (!next.length)
    {
      next = $(panelList).children('coral-panel').first();
    }
  
    next.attr('selected', '');
  
    $('#selectedIndexLabel').text('Selected Index: ' + panelList.items.getAll().indexOf(next[0]));
  });
});
</script>

Coral.PanelStack API

Constructor

JavaScript:

new Coral.PanelStack() or document.createElement('coral-panelstack')

HTML Tag:

<coral-panelstack>

Extends

Mixes In

Instance Properties

instance.hidden {Boolean}

Reflected
Whether this component is hidden or not.
Inherited From:
Default Value:
  • false
HTML Attribute:
  • hidden

instance.items {Coral.Collection}

Readonly
The Collection Interface that allows interacting with the items that the component contains. See Coral.Collection for more details.

instance.selectedItem {HTMLElement}

Readonly
The selected item of the PanelStack.

Methods

instance.get

Get the value of a property.
Parameters:
Name Type Description
property String The name of the property to fetch the value of.
Returns:
Property value. {*}
Inherited From:

instance.hide

Hide this component.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.off

Remove an event listener.
Parameters:
Name Type Optional Description
eventName String No
The event name to stop listening for.
selector String Yes
The selector that was used for event delegation.
func function No
The function that was passed to on().
useCapture Boolean Yes
Only remove listeners with useCapture set to the value passed in.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.on

Add an event listener.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to listen for.
selector String Yes
The selector to use for event delegation.
func function No
The function that will be called when the event is triggered.
useCapture Boolean Yes
Whether or not to listen during the capturing or bubbling phase.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.remove

Non-destructively remove this element. It can be re-added by simply appending it to the document again. It will be garbage collected if there are no more references to it. This is different from using jQuery's remove(), which is destructive in that it removes data and listeners.
Inherited From:

instance.set

Set a single property.
Parameters:
Name Type Description
property String The name of the property to set.
value * The value to set the property to.
silent Boolean If true, events should not be triggered as a result of this set.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.show

Show this component.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.trigger

Trigger an event.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to trigger.
props Object Yes
Additional properties to make available to handlers as event.detail.
bubbles Boolean Yes
Set to false to prevent the event from bubbling.
cancelable Boolean Yes
Set to false to prevent the event from being cancelable.
Returns:
CustomEvent object {CustomEvent}
Inherited From:

Events

coral-collection:add

Triggered when an item is added to the Collection. Collection events are not synchronous so the DOM may reflect a different reality although every addition or removal will be reported.
Callback Parameters:
Name Type Description
event Object

Event object.

Name Type Description
event.detail.item HTMLElement The item that was added.
Inherited From:

coral-collection:remove

Triggered when an item is removed from a Collection. Collection events are not synchronous so the DOM may reflect a different reality although every addition or removal will be reported.
Callback Parameters:
Name Type Description
event Object

Event object.

Name Type Description
event.detail.item HTMLElement The item that was removed.
Inherited From:

coral-component:attached

Triggered when the component is attached to the DOM.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:
Deprecated:
  • since 1.14.0, use MutationObserver instead.

    coral-component:detached

    Triggered when the component is detached to the DOM.
    Callback Parameters:
    Name Type Description
    event Object Event object.
    Inherited From:
    Deprecated:
    • since 1.14.0, use MutationObserver instead.

      coral-component:ready

      Triggerred when the component has been upgraded and is ready for use.
      Callback Parameters:
      Name Type Description
      event Object Event object.
      Inherited From:
      Deprecated:
      • since 1.9.0, use Coral.commons.ready() instead.

        coral-panelstack:change

        Triggered when the selected panel has changed.
        Callback Parameters:
        Name Type Description
        event Object

        Event object.

        Name Type Description
        event.detail.selection HTMLElement The new selected panel.
        event.detail.oldSelection HTMLElement The prior selected panel.

        Coral.Panel API

        Constructor

        JavaScript:

        new Coral.Panel() or document.createElement('coral-panel')

        HTML Tag:

        <coral-panel>

        Extends

        Mixes In

        Sub-components

        Instance Properties

        instance.content {HTMLElement}

        The panelstack items's content element.

        instance.hidden {Boolean}

        Reflected
        Whether this component is hidden or not.
        Inherited From:
        Default Value:
        • false
        HTML Attribute:
        • hidden

        instance.selected {Boolean}

        Whether the item is selected. When true, the item will appear as the active element in the PanelStack. The item must be a child of a PanelStack before this property is set to true. This property cannot be programmatically set to false.
        Default Value:
        • false
        HTML Attribute:
        • selected

        Methods

        instance.get

        Get the value of a property.
        Parameters:
        Name Type Description
        property String The name of the property to fetch the value of.
        Returns:
        Property value. {*}
        Inherited From:

        instance.hide

        Hide this component.
        Returns:
        this, chainable {Coral.Component}
        Inherited From:

        instance.off

        Remove an event listener.
        Parameters:
        Name Type Optional Description
        eventName String No
        The event name to stop listening for.
        selector String Yes
        The selector that was used for event delegation.
        func function No
        The function that was passed to on().
        useCapture Boolean Yes
        Only remove listeners with useCapture set to the value passed in.
        Returns:
        this, chainable. {Coral.Component}
        Inherited From:

        instance.on

        Add an event listener.
        Parameters:
        Name Type Optional Default Description
        eventName String No
        The event name to listen for.
        selector String Yes
        The selector to use for event delegation.
        func function No
        The function that will be called when the event is triggered.
        useCapture Boolean Yes
        Whether or not to listen during the capturing or bubbling phase.
        Returns:
        this, chainable. {Coral.Component}
        Inherited From:

        instance.remove

        Non-destructively remove this element. It can be re-added by simply appending it to the document again. It will be garbage collected if there are no more references to it. This is different from using jQuery's remove(), which is destructive in that it removes data and listeners.
        Inherited From:

        instance.set

        Set a single property.
        Parameters:
        Name Type Description
        property String The name of the property to set.
        value * The value to set the property to.
        silent Boolean If true, events should not be triggered as a result of this set.
        Returns:
        this, chainable. {Coral.Component}
        Inherited From:

        instance.show

        Show this component.
        Returns:
        this, chainable {Coral.Component}
        Inherited From:

        instance.trigger

        Trigger an event.
        Parameters:
        Name Type Optional Default Description
        eventName String No
        The event name to trigger.
        props Object Yes
        Additional properties to make available to handlers as event.detail.
        bubbles Boolean Yes
        Set to false to prevent the event from bubbling.
        cancelable Boolean Yes
        Set to false to prevent the event from being cancelable.
        Returns:
        CustomEvent object {CustomEvent}
        Inherited From:

        Events

        coral-component:attached

        Triggered when the component is attached to the DOM.
        Callback Parameters:
        Name Type Description
        event Object Event object.
        Inherited From:
        Deprecated:
        • since 1.14.0, use MutationObserver instead.

          coral-component:detached

          Triggered when the component is detached to the DOM.
          Callback Parameters:
          Name Type Description
          event Object Event object.
          Inherited From:
          Deprecated:
          • since 1.14.0, use MutationObserver instead.

            coral-component:ready

            Triggerred when the component has been upgraded and is ready for use.
            Callback Parameters:
            Name Type Description
            event Object Event object.
            Inherited From:
            Deprecated:
            • since 1.9.0, use Coral.commons.ready() instead.