Skip to content

fix(ui): a host's root font size no longer shrinks the side panel - #242

Merged
Ardnived merged 5 commits into
mainfrom
fix/238-root-font-panel
Oct 1, 2026
Merged

Ardnived merged 5 commits into
mainfrom
fix/238-root-font-panel

Conversation

@Ardnived

@Ardnived Ardnived commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • A host's root font size (html { font-size: 62.5% }) no longer shrinks the side panel: it is 352px everywhere.
  • The map camera's left padding (DRAWER_W_PX = 352) now matches the panel's rendered width on every host.
  • pnpm build fails on any rem length in the injected CSS outside the calendar's Schedule-X chunk.

Changes

  • src/hooks/use-map-controller-real.tsx — DRAWER_W_REM = 22 / × 16 becomes DRAWER_W_PX = 352, used directly for the padding. The "one half of a pair" comment names the px pair and drops the root-font caveat it no longer has.
  • Drawer.tsx, DrawerStack.tsx, story-harness.tsx — --sy-drawer-w fallback 22rem → 352px, --sy-content-max 32rem → 512px, calc(100%-2rem) → -32px, cog offsets +2rem/+3rem → +32px/+48px.
  • ActionRow.tsx max-w-[6rem] → [96px]; Modal.tsx calc(…-2rem) → -32px; App.tsx root fallback inline style → px.
  • globals.css (swiper pagination offset, expanded-dialog control nudge) and the vendored vaul.css (handle radius, 44px hit area) → px. The vendoring header now says to re-convert on refresh.
  • use-map-controller.test.ts — the pairing spec captures the fallback's unit, so a rem fallback fails it, and it pins that the padding reads DRAWER_W_PX.
  • scripts/assert-css-scoped.mjs — check 4: no rem in any injected declaration unless the injecting chunk is CalendarView-*.js.
  • src/AGENTS.md, tailwind.config.js — state the px-only rule (the old max-w-[6rem] example is now max-w-[96px]).

Contract impact

Host-observable, so docs/embedding.md ("What the widget does to your page") and CHANGELOG.md (Unreleased → Fixed) both say it: a host's root font size no longer resizes the widget, and the calendar view's text is the one part still in rem. Consumers: SahajAtlasWordpress (its browser lane's twentytwenty / oceanwp / root-font / fixed-header cells found this) and WeMeditateWeb's /map host. Neither needs a code change. Nothing changes in the script URL, the CSP, or the sizing rules.

Test results

  • Lean gate (.claude/skills/pr-prep/check.sh, after rebasing on fix(widget): compact card's overlay opens with no interface #234): ✓ lint, ✓ typecheck, ✓ 125 files / 1620 tests
  • pnpm build: ✓ assert-css-scoped: 1172 rules across 3 injected stylesheet(s) confined to .sy-atlas, with no rem outside the calendar chunk; ✓ assert:maps
  • pnpm size: ✓ standalone 301.9 / 308 KiB, loader 2.6 / 3.5 KiB, embed 303.7 / 308 KiB
  • New gate seen failing:
    • against the pre-fix dist/, it listed the 14 known lengths
    • with max-w-[6rem] put back, pnpm build exited 1 naming .max-w-\[6rem\] { max-width: 6rem }
    • with a detector that matches nothing, its proof-of-life branch failed
  • Pairing spec seen failing: with a 22rem fallback put back in DrawerStack and a literal 352 in the padding, both assertions went red. Restored, both pass.

Manual verification

Measured in Chromium (Playwright, 1280×720, map mode, clients/me stubbed). The host page's <sahaj-atlas> loads auto.js from pnpm review:embed. All other SahajCloud reads were proxied to production with the published key, so the list shows live countries. [data-vaul-drawer] once it settles:

Build Host root Panel width Link labels wrapped Mid-word breaks
main 62.5% (10px) 220px Online Classes, United Kingdom, United States, New Zealand 0
main default (16px) 352px none 0
this branch 62.5% (10px) 352px none 0 (of 1932 words)
this branch default (16px) 352px none 0

Still to do after deploy (the issue's checklist item, not run here): SahajAtlasWordpress's browser lane on the twentytwenty and root-font cells should report no "side panel keeps its width" finding.

Notes for reviewer

  • The calendar exemption is by chunk filename (CalendarView-*.js). If the chunk is renamed, the build fails and the message names REM_EXEMPT_CHUNK. Finding no rem in the calendar chunk also fails. That second check is the detector's proof of life: a regex that silently stopped matching the minifier's output would otherwise pass every sheet.
  • Schedule-X's theme CSS is left in rem, on purpose. It is third-party and pinned. On a 62.5% host the calendar's text renders smaller. The guide and the changelog both say so.
  • Media-query params are not checked: a media query's rem is the browser's initial font size, which a page cannot change.
  • Security-review trigger paths (src/App.tsx, src/styles/, scripts/*css*) are touched. The diff only changes length units and adds a read-only check to the gate. No selector, scope, or injection changes; assert-css-scoped still confines every rule.
  • The issue's "Kingdo/m" mid-word break did not reproduce in my harness (labels wrapped at spaces). It likely needs a theme's own word-break / overflow-wrap. At 352px nothing wraps either way.
Detail
  • Why px rather than resolving the width at runtime: the camera padding is a constant on purpose (no DOM read in the map's hot path; see the pair comment). With both halves in px, nothing a host does to html can separate them.
  • Why extend assert-css-scoped rather than a sibling script: it already extracts every injected sheet with its chunk name and fails when it finds nothing, or fewer sheets than injection sites. A sibling would either duplicate that or import a module whose top level runs the scoping gate.
  • Per-injection, not per-unique-sheet: the existing dedupe keys on CSS text. The rem check is decided per injecting file, so an identical copy injected from another chunk cannot inherit the calendar's exemption.
  • Rem survey of the pre-fix build: main sheet 14 lengths (all converted here); lightbox sheet 0; calendar sheet 40 (Schedule-X; exempt). The Mapbox search web bundle's runtime CSS has no rem lengths.
  • Comments still mentioning rem (left alone): Dropdown's // 224px (14rem) equivalence notes, the Modal comment quoting its old 100vw-2rem defence, and a hypothetical media query in responsive.test.ts.
  • Verification environment: another worktree's review server held :5174 during the first pass, so the pre-rebase measurement ran on a temporary copy of the script on :5184 (and the main baseline on :5194, built from git archive origin/main). The post-rebase measurement used pnpm review:embed on :5174 itself. Each server was stopped by its own PID.

Closes #238

🤖 Generated with Claude Code

Ardnived and others added 3 commits October 1, 2026 12:00
A host that sets `html { font-size: 62.5% }` (Twenty Twenty, OceanWP)
rescaled every rem the widget still shipped: the side panel measured
220px instead of 352px, list labels wrapped, and the map camera kept
padding for a 352px panel.

Converts the residue TAILWIND_REM_TO_PX did not cover: the drawer width
fallback (22rem -> 352px) in the Drawer atom and DrawerStack, the content
cap (32rem -> 512px), the cog offsets, ActionRow's max width, the Modal's
margins, the story harness panel, the root fallback's inline style, and
the rem lengths in globals.css and the vendored vaul.css.

The camera half of the pair becomes DRAWER_W_PX = 352, used directly for
the left padding, and the pairing spec now captures the fallback's unit,
so a rem fallback fails it as well as a mismatched number.

Schedule-X's theme CSS stays in rem: it is third-party and loads only
with the calendar.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
assert-css-scoped gains a fourth check. It reads every injected
stylesheet back out of dist/, as it already does for scoping, and fails
on any declaration carrying a rem length unless the injecting chunk is
CalendarView's (Schedule-X's theme). Media-query params are not checked:
their rem is the browser's initial font size, which no page can change.

The calendar's own rem lengths double as the detector's proof of life:
finding none there fails the gate too, so a renamed chunk or a detector
that stopped matching the minifier's output cannot pass every sheet blind.
The exemption is decided per injecting file, not per unique sheet.

Verified both ways: the pre-fix dist fails with the 14 known lengths,
and reintroducing `max-w-[6rem]` fails `pnpm build`.

src/AGENTS.md and tailwind.config.js now state the px-only rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
States it in "What the widget does to your page", with the calendar's
third-party grid named as the one part still sized in rem, and records
the fix under Unreleased -> Fixed in the changelog.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: c384ac9
Status: ✅  Deploy successful!
Preview URL: https://64e90c0d.sahajatlas.pages.dev
Branch Preview URL: https://fix-238-root-font-panel.sahajatlas.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: c384ac9
Status: ✅  Deploy successful!
Preview URL: https://42e86dd3.sahajatlas-design.pages.dev
Branch Preview URL: https://fix-238-root-font-panel.sahajatlas-design.pages.dev

View logs

@Ardnived
Ardnived merged commit 673ec9b into main Oct 1, 2026
10 checks passed
@Ardnived
Ardnived deleted the fix/238-root-font-panel branch October 1, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(ui): a host's root font size shrinks the side panel

1 participant