reintroduce bitty and add progressive enhancement and tabs

This commit is contained in:
2026-05-28 06:41:59 +03:00
parent d2ea0bbd51
commit 160629fca7
6 changed files with 65 additions and 16 deletions

25
data/static/js/bits/ui.js Normal file
View File

@@ -0,0 +1,25 @@
export const b = {}
export function setTab(_, sender, el) {
if (sender.ariaSelected === 'true') {
return;
}
if (!el.contains(sender)) {
return;
}
const tabIndex = parseInt(sender.dataset.tabIndex);
const tabPanels = el.querySelectorAll('.tab-content');
const tabButtons = el.querySelectorAll('.tab-bar button');
for (let i = 0; i < tabPanels.length; i++) {
const tabPanel = tabPanels[i];
const tabButton = tabButtons[i];
if (i === tabIndex) {
tabPanel.classList.remove('hidden');
tabButton.ariaSelected = 'true';
} else if (!tabPanel.classList.contains('hidden')) {
tabPanel.classList.add('hidden');
tabButton.ariaSelected = 'false';
}
}
}