From 265cb20fab62717496177099881beb722de3d5d2 Mon Sep 17 00:00:00 2001 From: Wynne Pirini Date: Fri, 6 Nov 2026 09:48:05 +1300 Subject: [PATCH 1/2] feat(admin): mobile shell with a nav drawer, header and scrolling content (#226) Phase 1 of #226, one file as scoped: frontend/src/routes/+layout.svelte. The sidebar was w-56 with no breakpoint, so a 390px phone had 224px of chrome and 166px for content; the wrapper's overflow-hidden then clipped rather than scrolled. Every route was unusable below md. - Below md the sidebar is an off-canvas drawer: fixed, w-72 capped at 85vw, with a backdrop. From md up it is the same node, static at w-56 as before. - A compact md:hidden header carries the menu button and the user's name. - The drawer closes on navigation (route effect and link clicks), on Escape, and when the viewport grows past md, so it cannot linger over the desktop layout. - The closed drawer sets "visibility: hidden" rather than only a transform, so its links stay out of the tab order; while it is open
is inert. - Content area: min-h-0/min-w-0 so it scrolls inside the flex column, and padding drops to px-4 py-4 on small screens (was px-8 py-8 everywhere). Verified in a real browser at 390, 800 and 1280 px: - 390: sidebar hidden, header flex, main 390 wide, document scrollWidth 390 (no horizontal overflow), drawer opens to 288px with backdrop and main inert, Escape closes, nav click navigates and closes. - 800/1280: sidebar visible, static, 224px, header hidden - desktop unchanged. - /admin/settings at 390: main scrollHeight 1730 vs clientHeight 803, scrolls to 400. Content scrolls instead of clipping. No automated viewport test: the existing visual suite mounts shadcn components in isolation with a standalone svelte() (not sveltekit()) config, so it cannot render +layout.svelte, which needs $app/stores, $app/paths and a live /v1/users/me. Real coverage needs a route-level browser test against a seeded server, which is new infra. Flagging rather than silently skipping it. Out of scope, unchanged: page-level headers still squeeze at 390 (the bookings title truncates against its buttons) - that is phases 2/3. --- frontend/src/routes/+layout.svelte | 74 +++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 7 deletions(-) diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index 856a229d..0ea1be22 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -18,6 +18,9 @@ let reportOpen = $state(false); let recordingsConfigured = $state(false); let version = $state(''); + // Mobile nav drawer. Only ever opened from the md:hidden header button, so it is + // always false at desktop widths — which is what makes `inert` on
safe. + let sidebarOpen = $state(false); const ISSUES_URL = 'https://github.com/Calnode/calnode/issues'; const NEW_ISSUE_URL = 'https://github.com/Calnode/calnode/issues/new/choose'; @@ -130,7 +133,22 @@ ) ); + // Close the mobile drawer whenever the route changes, so tapping a nav link does not + // leave it open over the page it just navigated to. + $effect(() => { + void $page.url.pathname; + sidebarOpen = false; + }); + onMount(async () => { + // Close the drawer if the viewport grows past md while it is open, so it cannot + // linger as an active overlay over the desktop layout. + const desktop = window.matchMedia('(min-width: 768px)'); + const onDesktop = (e: MediaQueryListEvent) => { + if (e.matches) sidebarOpen = false; + }; + desktop.addEventListener('change', onDesktop); + if (isPublicRoute) { checking = false; return; @@ -180,6 +198,12 @@ } + { + if (e.key === 'Escape' && sidebarOpen) sidebarOpen = false; + }} +/> + {#if isPublicRoute} @@ -193,11 +217,43 @@ {#if $authStatus.demo_mode} {/if} -
- -