import { Controller } from "stimulus" export default class extends Controller { static targets = ["tab", "tabContent"] openTab(evt) { const tab = evt.currentTarget; const tabName = tab.dataset.tabsName; this.tabTargets.forEach(el => el.classList.remove('is-active')); evt.currentTarget.classList.add('is-active'); this.tabContentTargets.forEach(el => { if (el.dataset.tabsFor === tabName) { el.style.display = 'inherit'; } else { el.style.display = 'none'; } }); } }