Sha256: f15a4bc45624dd311f4f9ab678a16c096a4f230e449407c05f025861c7c34d7c
Contents?: true
Size: 1.29 KB
Versions: 90
Compression:
Stored size: 1.29 KB
Contents
import { Controller } from '@hotwired/stimulus'; class TabNavComponent extends Controller { constructor() { super(...arguments); // keep in synch with tab_nav_component this.SELECTED_CLASSES = ['ariadne-border-slate-500', 'ariadne-text-slate-600']; this.UNSELECTED_CLASSES = ['ariadne-text-gray-500', 'hover:ariadne-text-gray-700', 'hover:ariadne-border-gray-300']; } connect() { for (const tab of this.tabTargets) { if (tab.hasAttribute('aria-current')) { tab.classList.add(...this.SELECTED_CLASSES); tab.classList.remove(...this.UNSELECTED_CLASSES); } } } toggle(event) { for (const tab of this.tabTargets) { if (tab === event.target) { tab.setAttribute('aria-current', 'page'); tab.classList.add(...this.SELECTED_CLASSES); tab.classList.remove(...this.UNSELECTED_CLASSES); } else if (tab.hasAttribute('aria-current')) { tab.removeAttribute('aria-current'); tab.classList.add(...this.UNSELECTED_CLASSES); tab.classList.remove(...this.SELECTED_CLASSES); } } } } TabNavComponent.targets = ['tab']; export default TabNavComponent;
Version data entries
90 entries across 90 versions & 1 rubygems