feat: extract collapsible container into partial
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user