Hi, I am struggling a lot with tabs for my plugin in react/typescript.
For vanilla plugin I used code from ui-kitchen-sink plugin sample
<div class="sp-tabs">
<div class="sp-tab selected" id="sp-spectrum-typography-tab"><sp-label>Spectrum Typography</sp-label></div>
<div class="sp-tab" id="sp-spectrum-widgets-tab"><sp-label>Spectrum Widgets</sp-label></div>
<div class="sp-tab" id="sp-native-tab"><sp-label>Native</sp-label></div>
<div class="sp-tab" id="sp-html-tab"><sp-label>HTML</sp-label></div>
<div class="sp-tab" id="sp-events-tab"><sp-label>Events</sp-label></div>
<div class="sp-tab-page visible" id="sp-spectrum-typography-tab-page">
//content
</div>
...
</div>
and
theTab.onclick = () => {
localStorage.setItem("currentTab", theTab.getAttribute("id"));
Array.from(document.querySelectorAll(".sp-tab")).forEach(aTab => {
if (aTab.getAttribute("id") === theTab.getAttribute("id")) {
aTab.classList.add("selected");
} else {
aTab.classList.remove("selected");
}
});
Array.from(document.querySelectorAll(".sp-tab-page")).forEach(tabPage => {
if (tabPage.getAttribute("id").startsWith(theTab.getAttribute("id"))) {
tabPage.classList.add("visible");
} else {
tabPage.classList.remove("visible");
}
});
}
});
unfortunately I can’t make it work for React.
Can anyone help me a little bit with that?