Sha256: 456407f7760439d5cb0de984af46822dd872623c4c129a025045e3a9702ac790
Contents?: true
Size: 750 Bytes
Versions: 3
Compression:
Stored size: 750 Bytes
Contents
import { Controller } from "@hotwired/stimulus" export default class extends Controller { static targets = [ "button", "tab" ] static values = { index: Number } indexValueChanged() { this.#showSelectedTab() } select({ target }) { this.indexValue = target.dataset.index } prev() { if (this.indexValue > 0) this.indexValue-- } next() { if (this.indexValue < this.#lastIndex) this.indexValue++ } #showSelectedTab() { this.buttonTargets.forEach((element, index) => { element.ariaSelected = index === this.indexValue }) this.tabTargets.forEach((element, index) => { element.hidden = index !== this.indexValue }) } get #lastIndex() { return this.tabTargets.length -1 } }
Version data entries
3 entries across 3 versions & 1 rubygems