2026-07-31 17:41:55 +03:00
|
|
|
import { Controller } from '@hotwired/stimulus'
|
|
|
|
|
|
|
|
|
|
export default class extends Controller {
|
|
|
|
|
static targets = ['button', 'panel']
|
|
|
|
|
|
|
|
|
|
show(event) {
|
2026-09-22 19:00:34 +03:00
|
|
|
this.activate(event.currentTarget.dataset.panel)
|
2026-07-31 17:41:55 +03:00
|
|
|
}
|
|
|
|
|
|
2026-09-22 19:00:34 +03:00
|
|
|
activate(panelId) {
|
2026-07-31 17:41:55 +03:00
|
|
|
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}`
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|