feat: extract collapsible container into partial

This commit is contained in:
Björn Fromme
2026-08-17 16:07:26 +02:00
parent a5d97f1206
commit f00351706e
4 changed files with 69 additions and 50 deletions
+5 -1
View File
@@ -2,7 +2,7 @@ import {Controller} from '@hotwired/stimulus'
export default class extends Controller {
static classes = ['closed', 'open', 'iconOpen']
static targets = ['content', 'icon', 'container']
static targets = ['content', 'icon', 'container', 'trigger']
static values = {
open: {
type: Boolean,
@@ -43,6 +43,10 @@ export default class extends Controller {
this.iconTarget.classList.toggle(iconClass, true === open)
}
if (this.hasTriggerTarget) {
this.triggerTarget.setAttribute('aria-expanded', String(open))
}
// Toggle class on container element (or controller element) if specified
if (this.hasOpenClass) {
const container = this.hasContainerTarget ? this.containerTarget : this.element