Skip to content
Snippets Groups Projects
accordion-container.tsx 831 B
Newer Older
import {Component, Prop, h} from '@stencil/core';
Tuukka Turu's avatar
Tuukka Turu committed

@Component({
  tag: 'hy-accordion-container',
  styleUrl: 'accordion-container.scss',
  shadow: false
})
export class AccordionContainer {
Tuukka Turu's avatar
Tuukka Turu committed
  @Prop() accordionid?: string;

  /*
  * data-allow-toggle
    Allow for each toggle to both open and close individually

  data-allow-multiple
    Allow for multiple accordion sections to be expanded at the same time.
    Assumes data-allow-toggle otherwise you would not be able to close any of the accordions
  */

Tuukka Turu's avatar
Tuukka Turu committed
  render() {
    const classAttributes = ['hy-accordion-container', 'js-hy-accordion'];
    const id = this.accordionid.toLowerCase().replace(/\W/g, '-');
Tuukka Turu's avatar
Tuukka Turu committed
    return (
      <div id={id} class={classAttributes.join(' ')} data-allow-multiple="true" data-allow-toggle="true">
Tuukka Turu's avatar
Tuukka Turu committed
        <slot></slot>
      </div>
    );
  }
}