1 import {slideDown, slideUp} from '../services/animations.ts';
2 import {Component} from './component';
6 * Provides some simple logic to allow collapsible sections.
8 export class Collapsible extends Component {
11 this.container = this.$el;
12 this.trigger = this.$refs.trigger;
13 this.content = this.$refs.content;
16 this.trigger.addEventListener('click', this.toggle.bind(this));
17 this.openIfContainsError();
22 this.container.classList.add('open');
23 this.trigger.setAttribute('aria-expanded', 'true');
24 slideDown(this.content, 300);
28 this.container.classList.remove('open');
29 this.trigger.setAttribute('aria-expanded', 'false');
30 slideUp(this.content, 300);
34 if (this.container.classList.contains('open')) {
41 openIfContainsError() {
42 const error = this.content.querySelector('.text-neg.text-small');