From fb03d73e66cf73f0f4de3984c8d2dedae177ee25 Mon Sep 17 00:00:00 2001 From: mkelvers Date: Sat, 13 Jun 2026 19:22:29 +0200 Subject: [PATCH] chore: remove mobile menu shell module --- static/app.ts | 1 - static/shell.ts | 88 ------------------------------------------------- 2 files changed, 89 deletions(-) delete mode 100644 static/shell.ts diff --git a/static/app.ts b/static/app.ts index f3aec40..e712236 100644 --- a/static/app.ts +++ b/static/app.ts @@ -8,7 +8,6 @@ import "./timezone"; import "./search"; import "./sort_filter"; import "./dedupe"; -import "./shell"; import "./watchlist"; import "./top_pick_carousel"; import "./continue_watching_carousel"; diff --git a/static/shell.ts b/static/shell.ts deleted file mode 100644 index 8d7efd2..0000000 --- a/static/shell.ts +++ /dev/null @@ -1,88 +0,0 @@ -export {}; - -import { onReady } from "./utils"; - -const isMobileViewport = (): boolean => window.matchMedia("(max-width: 1023px)").matches; - -const initSidebarTransitions = (): void => { - requestAnimationFrame(() => { - document.documentElement.classList.add("sidebar-ready"); - }); -}; - -const initMobileMenu = (): void => { - const menu = document.getElementById("mobile-menu"); - const backdrop = document.getElementById("mobile-menu-backdrop"); - const toggle = document.querySelector("[data-mobile-menu-toggle]"); - - if (!(menu instanceof HTMLElement)) return; - if (!(backdrop instanceof HTMLElement)) return; - if (!(toggle instanceof HTMLElement)) return; - - const body = document.body; - let lastFocused: HTMLElement | null = null; - - const setOpen = (nextOpen: boolean): void => { - menu.dataset.mobileOpen = nextOpen ? "true" : "false"; - backdrop.dataset.mobileOpen = nextOpen ? "true" : "false"; - backdrop.classList.toggle("hidden", !nextOpen); - toggle.setAttribute("aria-expanded", nextOpen ? "true" : "false"); - body.classList.toggle("overflow-hidden", nextOpen); - }; - - const openMenu = (): void => { - if (!isMobileViewport()) return; - if (menu.dataset.mobileOpen === "true") return; - - lastFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null; - setOpen(true); - - const focusTarget = menu.querySelector( - 'a, button, input, [tabindex]:not([tabindex="-1"])', - ); - focusTarget?.focus(); - }; - - const closeMenu = (): void => { - if (menu.dataset.mobileOpen !== "true") return; - setOpen(false); - lastFocused?.focus(); - }; - - toggle.addEventListener("click", () => { - if (menu.dataset.mobileOpen === "true") { - closeMenu(); - return; - } - - openMenu(); - }); - - backdrop.addEventListener("click", closeMenu); - - document.addEventListener("keydown", (event) => { - if (event.key !== "Escape") return; - if (menu.dataset.mobileOpen !== "true") return; - event.preventDefault(); - closeMenu(); - }); - - menu.addEventListener("click", (event) => { - const target = event.target; - if (!(target instanceof Element)) return; - if (!target.closest("a, button")) return; - if (!isMobileViewport()) return; - closeMenu(); - }); - - window.addEventListener("resize", () => { - if (!isMobileViewport()) { - setOpen(false); - } - }); -}; - -onReady(() => { - initSidebarTransitions(); - initMobileMenu(); -});