Skip to content

feat(admin): mobile shell with a nav drawer, header and scrolling content (#226) - #227

Merged
shockalotti merged 2 commits into
mainfrom
feat/admin-mobile-shell
Nov 6, 2026
Merged

shockalotti merged 2 commits into
mainfrom
feat/admin-mobile-shell

Conversation

@shockalotti

Copy link
Copy Markdown
Contributor

Phase 1 of #226. One file, as scoped: frontend/src/routes/+layout.svelte.

The blocker

w-56 with no breakpoint meant 224px of chrome on a 390px phone, leaving ~166px, and the wrapper's overflow-hidden clipped instead of scrolling. Every route was unusable below md.

What changed

  • Drawer below md — the sidebar becomes fixed, w-72 capped at 85vw, with a backdrop. From md up it is the same node, static at w-56. No duplicated nav markup.
  • Compact header — md:hidden, carries the menu button and the user's name.
  • Closes on: navigation (route effect + link clicks), Escape, and crossing back above md, so it cannot linger as an invisible overlay.
  • Not just transformed when closed — it sets visibility: hidden, so its links stay out of the tab order rather than being focusable off-screen. While open, <main> is inert.
  • Content scrolls — min-h-0 / min-w-0 on the flex children, padding drops to px-4 py-4 on small screens.

Verified in a real browser

Viewport Result
390 sidebar hidden (width 0), header flex, main 390 wide, document scrollWidth 390 — no horizontal overflow
390, drawer open 288px panel, backdrop present, main.inert = true, aria-expanded="true"
390, Escape drawer hidden, main.inert = false
390, nav click navigates, drawer closes
800 / 1280 sidebar visible, static, 224px, header hidden — desktop unchanged
/admin/settings @ 390 scrollHeight 1730 vs clientHeight 803, scrolls to 400 — content scrolls, no longer clips

Screenshots taken at each step.

One gap, stated plainly

I did not add an automated viewport test. The existing visual suite mounts shadcn components in isolation under a standalone svelte() config (not sveltekit()), so it cannot render +layout.svelte — that needs $app/stores, $app/paths and a live /v1/users/me. Real coverage means a route-level browser test against a seeded server, which is new test infra, and the issue asked for no new infra. So I verified by hand instead and am flagging it rather than quietly skipping the constraint. If you want that harness, it is worth its own issue — it would also cover phases 2–4.

Deliberately untouched

Page-level headers still squeeze at 390 — on /admin/bookings the title truncates against its buttons. That is the page's own layout (phases 2/3), not the shell, and fixing it here would blur the phase boundary.

pnpm check: 0 errors. pnpm test:visual: 5 passed. pnpm build: clean.

🤖 Generated with Claude Code

…tent (#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 <main> 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The drawer can't scroll, so its own footer — Report an issue and Sign out — is unreachable on short viewports (a landscape phone is enough). Two smaller notes inline, plus a doc entry that now overstates the gap.

Reviewed changes

  • Off-canvas drawer below md — the sidebar node becomes fixed with a backdrop and -translate-x-full invisible when closed, staying static/w-56 from md up, so nav markup isn't duplicated.
  • Compact mobile header — md:hidden, with an aria-expanded hamburger and the user's name.
  • Four close paths — route effect, link/button clicks, Escape, and a matchMedia listener that closes it when the viewport crosses back above md.
  • Modal-ish semantics — <main> is inert while open, and visibility: hidden keeps the closed drawer out of the tab order.
  • Scrolling content — min-h-0 on the flex children plus responsive padding (px-4/py-4 at the small end).

ℹ️ The §18 "does not lay out below ~600px" entry now overstates the gap

docs/ARCHITECTURE.md §18 still opens with "The admin SPA does not lay out below ~600px", which was true before this PR and no longer is for the shell. That doc's own rule (§24) asks for the matching section to be updated in the same PR as the behaviour change, so the next person reading it would think the shell work is unstarted.

Technical details
# §18 known-gap entry needs rescoping

## Affected sites
- `docs/ARCHITECTURE.md:981` — "The admin SPA does not lay out below ~600px. On the settings
  pages the nav and the content sit in one flex row with no stacking breakpoint, so the
  content column is squeezed to near-zero width..." The shell half of this is fixed by
  this PR; the settings half is not.

## Required outcome
- The entry should say the outer shell stacks below `md` now (phase 1), and scope the
  remaining gap to what is still true: the settings sub-nav (`frontend/src/routes/settings/+layout.svelte`,
  `<div class="flex gap-8"><nav class="w-44 shrink-0">`) still doesn't stack, and the page
  grids/tables are still phase 2/3 work.

## Open questions for the human (optional)
- If #226 is going to land phases 2–4 shortly, leaving the entry until then is defensible —
  worth a one-line "phase 1 landed" amendment either way.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash | 𝕏

Comment thread frontend/src/routes/+layout.svelte Resolved
Comment thread frontend/src/routes/+layout.svelte Resolved
Comment thread frontend/src/routes/+layout.svelte Resolved
…cus (#226)

Addresses the pullfrog review on #227.

1. The drawer could not scroll. `nav` was `flex-1` with the default `min-height:
   auto`, so it refused to shrink below its content and pushed the footer ("Report
   an issue", "Sign out") past the bottom edge on any short viewport - a landscape
   phone is enough. Overflow from a `fixed` element does not extend the document's
   scroll area, so those controls were unreachable. nav is now
   `min-h-0 flex-1 overflow-y-auto`, keeping the user block and footer pinned.

2. The `matchMedia` guard was specified in px (768px) while every `md:` class
   compiles to 48rem. They only agree at the 16px default font size; at, say, 20px
   `md:` starts at 960px, so the drawer could be opened in the 768-959px band with
   no `change` event on widening - leaving `<main>` inert and the page unclickable.
   The query is now `(min-width: 48rem)`, in lockstep with the classes it guards.

3. Nothing moved focus. Opening left focus on the trigger the backdrop covers;
   closing hid the focused element (`visibility: hidden`), dropping focus to
   <body>. Opening now focuses the first control inside the drawer, and closing
   returns focus to the menu button.

Also rescopes the ARCHITECTURE §18 "does not lay out below ~600px" entry, per the
repo's own rule that the matching section changes in the same PR: the shell half is
done, the remaining gap is the settings sub-nav and the phase 2/3 page work.

Verified at 390x620 and 390x500 with the drawer open: nav scrollable (535 > 458),
"Sign out" bottom 584 inside a 620 panel, focus inside the drawer on open, focus
back on the trigger after Escape. Desktop at 1280 unchanged: sidebar visible,
static, 224px, header hidden, nav not scrollable.
@shockalotti

Copy link
Copy Markdown
Contributor Author

Addressed all three findings in a1a470a.

  1. Drawer could not scroll — confirmed and fixed. nav now min-h-0 flex-1 overflow-y-auto, so it shrinks and scrolls while the user block and footer stay pinned. At 390×500 with the drawer open: nav 535 scroll / 458 client, "Sign out" bottom 584 inside the panel, both footer controls reachable.
  2. px vs rem threshold — right, and the failure mode is nasty: at a 20px default font the drawer opens in the 768–959px band and widening fires no change, leaving <main> inert. Query is now (min-width: 48rem).
  3. Focus — opening focuses the first control inside the drawer; closing returns focus to the menu button. Verified: focus inside the panel on open, back on the trigger after Escape.

Also rescoped the ARCHITECTURE §18 entry as suggested — the shell half is done, and the entry now names what actually remains (settings sub-nav, phase 2/3 page work) instead of implying nothing has started.

Re-verified desktop at 1280: sidebar visible/static/224px, header hidden, nav not scrollable. pnpm check 0 errors, pnpm test:visual 5 passed.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found. Commit a1a470a closes out all three findings from the last review, and the follow-up code is correct as far as I can trace it.

Reviewed changes

  • Drawer content now scrolls — nav is min-h-0 flex-1 overflow-y-auto, so the footer (Report an issue, Sign out) stays reachable on short viewports instead of being pushed past the panel; the desktop sidebar gets the same protection.
  • Focus moves with the drawer — bind:this refs on the aside and the hamburger, plus an $effect that focuses the first control in the panel on open and returns focus to the trigger on close, guarded by a plain drawerWasOpen flag so the return only fires for an actual open→closed transition.
  • matchMedia threshold expressed in rem — (min-width: 48rem) now matches the md: utilities exactly, so a non-default browser font size can no longer leave sidebarOpen true (and <main> inert) in the band where the trigger is already hidden.
  • §18 known-gap entry re-scoped — the entry now says "does not fully lay out", records that phase 1 landed, and scopes what remains to the settings sub-nav (still flex gap-8 with a w-44 shrink-0 nav) plus the phase 2/3 list and form work.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash | 𝕏

@shockalotti

Copy link
Copy Markdown
Contributor Author

Merged. This fixes something that was genuinely broken: 224px of fixed chrome on a 390px phone left no usable page, and overflow-hidden meant it clipped instead of scrolling.

Two things worth recording for whoever picks up phase 2:

  1. The media-query listener is never removed. onMount(async () => …) cannot return a cleanup function, so desktop.addEventListener("change", onDesktop) at line 172 accumulates on every remount. In practice the layout mounts once for the app lifetime, so it is not a bug you will see, but it will show up in HMR and it is two lines to fix: move the listener to a $effect that returns () => desktop.removeEventListener(...), or to a non-async onMount.

  2. The rem-not-px reasoning is right and should stay documented. Matching md: at 48rem rather than 768px means the listener fires exactly where the breakpoint actually is, including when a user has changed their default font size. That is the kind of thing that gets "simplified" later by someone who does not know why, so it is good that the comment explains it.

The focus handling (move into the drawer on open, back to the trigger on close, visibility: hidden so links leave the tab order) is more than most mobile drawers get, and the measurements in the description made this quick to trust.

@shockalotti
shockalotti merged commit 154901a into main Nov 6, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant