aboutsummaryrefslogtreecommitdiffstats
path: root/static/app.js
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-11 10:06:55 +0100
committerDanilo M. <danix@danix.xyz>2026-11-11 10:06:55 +0100
commit6a9a1ae47e758afb9a747a619b5665cb5908834a (patch)
treef521aa1dbbaee95a10a220597e44a182aaa0dd39 /static/app.js
parent79d3be64f0a3e4552b08c80f1678649ccbff2a7c (diff)
downloaddeck-it-6a9a1ae47e758afb9a747a619b5665cb5908834a.tar.gz
deck-it-6a9a1ae47e758afb9a747a619b5665cb5908834a.zip
feat(tabs): slide transition, OBS logo and a 3D-printer nozzle for K1C
A tab change slides the new tab in from the side it sits on in the bar (40px and a fade over 220ms, off under prefers-reduced-motion); #tab-body no longer scrolls sideways, so the slide never flashes a scrollbar. A tab can show a brand logo from static/logos instead of a glyph: OBS uses the OBS Studio logo (simple-icons). K1C's printer glyph becomes nf-md-printer_3d_nozzle; the Creality logo exists only as a wordmark, unreadable at tab size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'static/app.js')
-rw-r--r--static/app.js22
1 files changed, 17 insertions, 5 deletions
diff --git a/static/app.js b/static/app.js
index a15c2de..c91876b 100644
--- a/static/app.js
+++ b/static/app.js
@@ -26,9 +26,11 @@ const refreshers = [];
const TAB_KEY = "deckit.tab";
const tabs = {};
-// Tab icons, Font Awesome glyphs in the Nerd Font the server serves; a tab
-// not listed shows its name. The name also shows next to the active one.
-const TAB_ICONS = { Dashboard: "\uf0e4", Windows: "\uf2d2", OBS: "\uf03d", Assistant: "\uf086", K1C: "\uf02f" };
+// Tab icons, glyphs in the Nerd Font the server serves, or a brand logo from
+// static/logos; a tab with neither shows its name. The name also shows next
+// to the active one.
+const TAB_ICONS = { Dashboard: "\uf0e4", Windows: "\uf2d2", Assistant: "\uf086", K1C: "\u{f0e5b}" };
+const TAB_LOGOS = { OBS: "obs" };
function ensureTab(name) {
if (tabs[name]) return tabs[name];
@@ -36,10 +38,10 @@ function ensureTab(name) {
button.dataset.tab = name;
button.setAttribute("aria-label", name);
button.title = name;
- button.innerHTML = `<i class="nf"></i><span></span>`;
+ button.innerHTML = TAB_LOGOS[name] ? `<i class="brand ${TAB_LOGOS[name]}"></i><span></span>` : `<i class="nf"></i><span></span>`;
button.firstElementChild.textContent = TAB_ICONS[name] ?? "";
button.lastElementChild.textContent = name;
- if (!TAB_ICONS[name]) button.classList.add("named");
+ if (!TAB_ICONS[name] && !TAB_LOGOS[name]) button.classList.add("named");
button.onclick = () => showTab(name);
tabBar.append(button);
const section = document.createElement("section");
@@ -64,8 +66,18 @@ function sortTabs() {
}
}
+// The new tab slides in from the side it sits on in the bar.
+const slide = matchMedia("(prefers-reduced-motion: reduce)");
function showTab(name) {
keep();
+ const order = [...tabBar.children].map((b) => b.dataset.tab);
+ const from = order.findIndex((n) => !tabs[n]?.section.hidden);
+ const to = order.indexOf(name);
+ if (from !== -1 && from !== to && !slide.matches) {
+ const dx = to > from ? "40px" : "-40px";
+ tabs[name].section.animate([{ transform: `translateX(${dx})`, opacity: 0 }, { transform: "none", opacity: 1 }],
+ { duration: 220, easing: "cubic-bezier(.2, .8, .2, 1)" });
+ }
for (const [n, tab] of Object.entries(tabs)) {
tab.section.hidden = n !== name;
tab.button.classList.toggle("active", n === name);