Combine dashboard top 10 lists into one tabbed card
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f5bcc55a29
commit
393ebcdf0c
5 files changed
+163
-53
No files matched your search
@@ -52,3 +52,59 @@
|
||||
|
||||
save(expanded);
|
||||
})();
|
||||
|
||||
(() => {
|
||||
const storageKey = "flypaper.tab";
|
||||
const tabs = [...document.querySelectorAll('[role="tab"]')];
|
||||
if (tabs.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const select = (tab, focus) => {
|
||||
for (const other of tabs) {
|
||||
const selected = other === tab;
|
||||
other.setAttribute("aria-selected", String(selected));
|
||||
other.tabIndex = selected ? 0 : -1;
|
||||
document.getElementById(other.getAttribute("aria-controls")).hidden = !selected;
|
||||
}
|
||||
|
||||
if (focus) {
|
||||
tab.focus();
|
||||
}
|
||||
|
||||
try {
|
||||
sessionStorage.setItem(storageKey, tab.id);
|
||||
} catch {
|
||||
}
|
||||
};
|
||||
|
||||
let stored = null;
|
||||
try {
|
||||
stored = sessionStorage.getItem(storageKey);
|
||||
} catch {
|
||||
}
|
||||
|
||||
const initial = tabs.find(tab => tab.id === stored);
|
||||
if (initial) {
|
||||
select(initial, false);
|
||||
}
|
||||
|
||||
for (const tab of tabs) {
|
||||
tab.addEventListener("click", () => select(tab, false));
|
||||
|
||||
tab.addEventListener("keydown", event => {
|
||||
const index = tabs.indexOf(tab);
|
||||
const target = {
|
||||
ArrowRight: tabs[(index + 1) % tabs.length],
|
||||
ArrowLeft: tabs[(index - 1 + tabs.length) % tabs.length],
|
||||
Home: tabs[0],
|
||||
End: tabs.at(-1)
|
||||
}[event.key];
|
||||
|
||||
if (target) {
|
||||
event.preventDefault();
|
||||
select(target, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user