generated from boboko/starter
setting up front 1
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { Controller } from '@hotwired/stimulus'
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ['button', 'panel']
|
||||
|
||||
show(event) {
|
||||
this.#activate(event.currentTarget.dataset.panel)
|
||||
}
|
||||
|
||||
#activate(panelId) {
|
||||
this.buttonTargets.forEach(btn => {
|
||||
const active = btn.dataset.panel === panelId
|
||||
btn.classList.toggle('is-active', active)
|
||||
btn.setAttribute('aria-selected', String(active))
|
||||
})
|
||||
|
||||
this.panelTargets.forEach(panel => {
|
||||
panel.hidden = panel.id !== `tab-panel-${panelId}`
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user