Add device visibility and responsive navigation for 1.10.0
CMS quality / php (8.2) (push) Canceled after 0s
CMS quality / php (8.4) (push) Canceled after 0s
CMS quality / browser (push) Canceled after 0s
CMS quality / mysql (push) Canceled after 0s

This commit is contained in:
kantarci committed 2026-09-14 14:46:55 +02:00
1 parent eea6747d9e
commit 37c2942d1d
18 files changed
+493 -26

No files matched your search

+11 -3
View File
@@ -25,14 +25,19 @@
panels[index].querySelector('.tabs-heading')?.classList.add('visually-hidden');
});
const available = () => links.map((link, i) => getComputedStyle(link.parentElement).display !== 'none' ? i : -1).filter(i => i >= 0);
let selected = -1;
const select = (index, moveFocus = true) => {
const visible = available();
if (!visible.includes(index)) index = visible[0] ?? -1;
selected = index;
links.forEach((link, i) => {
const current = i === index;
link.setAttribute('aria-selected', String(current));
link.tabIndex = current ? 0 : -1;
panels[i].hidden = !current;
});
if (moveFocus) links[index].focus();
if (moveFocus && index >= 0) links[index].focus();
};
list.addEventListener('click', event => {
@@ -46,15 +51,18 @@
list.addEventListener('keydown', event => {
const index = links.indexOf(event.target.closest('a'));
if (index === -1) return;
const moves = { ArrowRight: index + 1, ArrowLeft: index - 1, Home: 0, End: links.length - 1 };
const visible = available(), position = visible.indexOf(index);
if (!visible.length) return;
const moves = { ArrowRight: position + 1, ArrowLeft: position - 1, Home: 0, End: visible.length - 1 };
if (!(event.key in moves)) return;
event.preventDefault();
select((moves[event.key] + links.length) % links.length);
select(visible[(moves[event.key] + visible.length) % visible.length]);
});
// A link from elsewhere may point straight at one panel.
const deepLink = panels.findIndex(panel => panel.id === location.hash.slice(1));
select(deepLink === -1 ? 0 : deepLink, false);
window.addEventListener('resize', () => select(selected, false));
group.classList.add('tabs-ready');
};