Skip to content

Instantly share code, notes, and snippets.

@Wolfr
Created April 8, 2021 17:35
Show Gist options
  • Save Wolfr/7a88068909f5cfc5df6473acc658ab48 to your computer and use it in GitHub Desktop.
Save Wolfr/7a88068909f5cfc5df6473acc658ab48 to your computer and use it in GitHub Desktop.
Accordion in Ember
<div class="auk-accordion {{if this.isActive "auk-accordion--is-active"}}">
<WebComponents::AuButtonLink
@padded="padded-y"
@icon="chevron-right"
@block="true"
{{on "click" this.toggleAccordion}}
aria-expanded={{if this.isActive "true" "false"}}
aria-controls={{this.accordionId}}>{{@label}}
</WebComponents::AuButtonLink>
<div
class="auk-accordion__content"
id={{this.accordionId}}
aria-hidden={{if this.isActive "false" "true"}}
>
{{yield}}
</div>
</div>
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { guidFor } from '@ember/object/internals';
export default class Accordion extends Component {
@tracked isActive = false
accordionId = 'accordion-' + guidFor(this);
@action
toggleAccordion() {
this.isActive = !this.isActive
}
}
<Accordion @label="My Accordion Title">
Content here...
</Accordion>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment