From 1575b9b53788d624eebb8acea15481420c5a69ee Mon Sep 17 00:00:00 2001 From: Timothy Date: Thu, 16 Jul 2026 21:57:29 +0200 Subject: [PATCH] fix(spa): add body margin + nav box-sizing resets (fixes #373, fixes #377) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two missing-base-reset defects in the ChicoryTV SPA shell, both confirmed by rendering the real app (not source-reading): - #373: the browser-default `body { margin: 8px }` was never reset, so it framed every full-viewport layout — the app shell and the shell-less `.ctv-auth-page` boot pages (login/setup/checking/error), both `min-height:100vh` — with a light border on all four edges. Fix: `html, body { margin: 0 }` + paint the app surface on `body` so any residual gap/overscroll stays dark (matches the design-system reset in forms.card.html / chicorytv-admin templates). Verified body margin 0 and no edge border on the boot page and the shell, warm theme, 1280px and 900px. - #377: the SPA ships no global `box-sizing` reset (default content-box), so `.ctv-nav-item { width:100%; padding:0 10px }` overflowed `.ctv-nav` (`overflow:auto`) by 20px → a horizontal scrollbar in the sidebar. Fix: scope `box-sizing: border-box` to `.ctv-nav-item`. Verified nav scrollWidth==clientWidth (216==216) and no horizontal scroll after the fix; the intended vertical nav scroll is unaffected. Docs: spa-conventions.md §1 records the base reset and the deliberate absence of a global box-sizing reset (set border-box locally when combining width:100% + padding). Co-Authored-By: Claude Opus 4.8 (1M context) --- docs/spa-conventions.md | 7 ++++++- web/src/components/components.css | 5 +++++ web/src/shell.css | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/spa-conventions.md b/docs/spa-conventions.md index 050dcb6a2..0e306666b 100644 --- a/docs/spa-conventions.md +++ b/docs/spa-conventions.md @@ -25,7 +25,12 @@ Vite + React + TypeScript, builds to `ErsatzTV/wwwroot/app` (see `web/vite.confi - **API clients**: `web/src/api/.ts` (see §4). - **Styling**: `web/src/shell.css` (+ `web/src/components/components.css`) — utility classes with a `ctv-` prefix (~690 occurrences across those two files). Reuse an existing `ctv-*` class before - inventing a new one. + inventing a new one. `shell.css` carries the only base reset — `html, body { margin: 0 }` plus + `body { background: var(--surface-app) }` (the 8px default body margin otherwise frames every + full-viewport layout with a light border, #373). **There is no global `box-sizing` reset** + (the SPA is authored under the default `content-box`), so any element that combines `width: 100%` + with padding/border must set `box-sizing: border-box` locally or it overflows its container — e.g. + `.ctv-nav-item` (#377). Prefer `width: auto` (shrink-to-fit) over `width: 100%` + padding where you can. ## 2. CRITICAL: sub-path screens must own their own pathname state diff --git a/web/src/components/components.css b/web/src/components/components.css index 1e873457e..6db4b7183 100644 --- a/web/src/components/components.css +++ b/web/src/components/components.css @@ -764,6 +764,11 @@ display: flex; align-items: center; gap: 10px; + /* The SPA ships no global box-sizing reset (default content-box), so width:100% + the + horizontal padding below would otherwise overflow .ctv-nav (overflow:auto) by 20px and + produce a horizontal scrollbar in the sidebar (#377). Border-box keeps the item exactly + the nav content width, padding included. */ + box-sizing: border-box; width: 100%; height: 34px; border: 0; diff --git a/web/src/shell.css b/web/src/shell.css index 1a9b7f06d..221358688 100644 --- a/web/src/shell.css +++ b/web/src/shell.css @@ -1,6 +1,17 @@ +/* Base reset on /: the browser-default body margin (8px) frames every + full-viewport layout — the app shell AND the shell-less .ctv-auth-page boot pages, both + min-height:100vh — exposing a light border on all sides (#373). Strip it and paint the app + surface so any residual gap/overscroll stays dark. Matches the design-system convention + (design-system/components/forms/forms.card.html, .../chicorytv-admin/*.html). */ +html, +body { + margin: 0; +} + /* Base typography on : Dialog (and any overlay) portals into document.body, outside .ctv-app-shell — without this, portaled UI falls back to the browser default font. */ body { + background: var(--surface-app); font-family: var(--font-sans, system-ui, sans-serif); font-size: var(--text-sm, 13px); color: var(--text-primary, #f0ebe4); -- 2.47.3