Repository navigation
Description
Summary
Make the widget degrade gracefully when a host gives it a slot too small for the full interface:
render a compact card with a button that opens the whole thing in a viewport-covering
overlay.
Two reasons this is next rather than later.
compact already exists as a documented parameter and nothing reads it. #149 added it to the
loader's config surface and docs/embedding.md describes its three values to hosts. A parameter we
document and then ignore is worse than one we never shipped — a host who sets compact=always
today gets silence.
The case is live, not hypothetical. sahajayoga.nl embeds the atlas at a hard-coded 400×600
and sahajayoga.at at 100%×600. Today the widget's only two answers are "fill your box" and "take
the whole viewport", so a 400×600 slot gets an interface that does not fit in it.
Stage E3 of the programme (.claude/reports/whitelabel-seo-program.md §7). E1/E2 — the iframe
document and its postMessage protocol — are deliberately not here: they are the larger half, and
both their candidate clients are unverified (#152).
Proposed changes
The predicate
embedForm(metrics) beside mapSlotWarning in src/lib/embed-slot.ts, whose docblock already
argues the map-mode requirement.
⚠ They must use different thresholds, and the docblock has to say why. mapSlotWarning asks
"did somebody clearly intend a box here?" — a relative question, thresholds deliberately slack
because a false positive costs one line in a stranger's console. embedForm asks "does the
interface fit?" — an absolute question, and a false positive now changes what renders.
Start at COMPACT_MAX_WIDTH_PX = 360 / COMPACT_MAX_HEIGHT_PX = 420, tuned in Ladle against
400×600 as the reference.
This also resolves what the slot warning was apologising for. A narrow map-mode slot currently
warns and then paints over the page anyway; it can now render compact instead. Keep the console
warning only where auto-detect was overridden off (compact=never plus a slot that does not fit) —
the host has said "don't", so a sentence is all that is left.
Who owns the decision
AppShell, and it matters that it is above MapProvider: in compact state the map must not
render at all, and mapbox-gl is the single largest second-hop cost in the app. Only AppShell sits
above it.
⚠ That saving is invisible to pnpm size by design — it budgets the eager graph and mapbox-gl
is a dynamic import. Say so in the PR rather than claiming a bundle win the gate cannot show.
DrawerStack keeps its own useIsWide(container) untouched: wide-vs-narrow and compact-vs-full are
different questions. Note src/config/responsive.test.ts's closed list of viewport callers is
unaffected, because this is a container reading — deliberate, not luck.
The overlay
Not the Modal atom. That is max-w-md with a title/description/× header; the expanded widget
wants the whole viewport with no chrome, and it contains vaul drawers, which are themselves Radix
Dialogs. A new surface on @radix-ui/react-dialog directly: fixed inset-0, no chrome, portaled to
overlayContainer() (never document.body — that is outside the style scope).
The docblock's first line should be the insight: expansion is not a new layout, it is map mode's
layout made explicit and reversible. A fixed; inset: 0 layer is exactly what map mode already
paints, which is why vaul's window-height arithmetic becomes correct rather than broken — the
widget genuinely does span the window. Nothing new has to be taught to vaul, and "not in the box"
stops being an accident and becomes a state with an entry and an exit.
Radix supplies the focus trap, focus restore to the Open button, Esc, aria-modal, and the host
<body> scroll lock that docs/embedding.md already documents as an honest exception. It needs an
sr-only Dialog.Title and aria-describedby={undefined}, the same dance ModalContent already
does.
The seam
One hook, src/hooks/use-expansion.tsx, with providers — the same shape as MapController, which
.claude/rules/components.md already blesses, so no component branches on whether expansion is
possible:
LocalExpansionProvider— renders the Radix overlay in-page.NoExpansionProvider— standalone;canExpand: false.
A third, framed provider lands with E1/E2. Designing for it now is what keeps that from being a
rewrite.
What the card shows
Reuse the wholesale feed — getGeojson is already fetched once and cached (WHOLESALE_GC_TIME), so
no new fetcher. Two or three rows through EventListItem, which is the repo's one React.memo
precisely because it takes what it needs as props rather than subscribing to the URL. The primary
button's label must be task-named, not product-named ("Find a class near you"), which serves the
de-branding work as well as the accessible name.
⚠ Entering compact mode logs a console warning naming the measured size and the threshold
(#149's diagnostic contract). A host who wanted the full interface needs to know they got the small
one and what to change.
⚠ AppShell is inside Suspense on clientQuery, so a 300px slot shows a full-height
LoadingFallback before the compact card. Minor, but it should be handled or noted.
Acceptance criteria
-
compact=always/never/autoall do whatdocs/embedding.mdsays, and an unrecognised value still resolves toauto. - A slot below the threshold renders the compact card; the map subtree does not mount and mapbox-gl is not fetched.
- The Open button expands to a viewport-covering overlay; Esc, focus trap and focus restore all work; the host page's scroll is locked while open and restored on close.
- vaul drawers inside the overlay compute their travel correctly — the reason the overlay is
fixed; inset: 0rather than contained. -
compact=neverin a slot that does not fit logs a console warning with the measured size and the threshold;autoentering compact logs one too. - The card's Open button has a task-named accessible label, and no brand string (the feat(ui): de-brand the widget and keep host CSS out of it #158 ratchet still passes).
- Reduced motion: the expand/collapse transition is framer-motion so
MotionConfigcovers it — not CSS, which would need a fourth seam. -
docs/embedding.md's sizing section documents the behaviour;CHANGELOG.mdrecords it. -
pnpm lint && pnpm typecheck && pnpm test:run && pnpm build && pnpm size && pnpm ladle:buildpass. - Write an implementation report to
.claude/reports/<issue-number>-<short-slug>.md.
Test strategy
Node lane: embedForm table-driven, mirroring mapSlotWarning's existing "stays quiet"
structure; the compact card's markup via renderToStaticMarkup (landmark name, button accessible
name, no brand string).
Ladle: the card at 400×600, which is the live reference case, plus the threshold boundaries.
Browser (Playwright MCP) — the two things no lane can answer, and the first is the biggest
unknown in this ticket:
- vaul nested inside a Radix Dialog. Both are
@radix-ui/react-dialog; nesting is supported in principle and the dismissible-layer and pointer-events interplay needs a real browser. ⚠ Memory records that Floating-UI popovers get pointer-locked out inside a modal vaul drawer — the same family of problem, so check the Dropdown atom inside the overlay too. - Expansion over an ancestor with
transform/contain: layout, which defeatposition: fixed(the measured table in.claude/rules/components.md).
Files affected
src/lib/embed-slot.ts—embedForm+ its thresholdssrc/components/organisms/CompactCard/(new, + stories)src/components/atoms/ExpandedSurface/(new, + stories)src/hooks/use-expansion.tsx(new)src/App.tsx—AppShellpicks the form, aboveMapProvidersrc/Widget.tsx,src/main.tsx— provider wiringdocs/embedding.md,CHANGELOG.md
References
.claude/reports/whitelabel-seo-program.md§7 — the design and the E1/E2 split- feat(widget): split the embed into a smart loader and an element bundle #149 — where
compactwas added to the config surface .claude/rules/components.md— theMapControllerseam shape, the reduced-motion seams, and the measured containing-block table
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Activity
fix(widget): stop the overlay locking a visitor out of the host page
fix(widget): tell the host the true thing about a slot that cannot fit
fix(ui): honour the geolocation dismissal, and survive a feed the car…
docs: Escape works now, and say what the floors actually measure
feat(ui): size the compact card to what the host's box can hold
refactor(widget): ask one question about the slot instead of three
feat(widget): make the compact card work in an iframe
feat(widget): decide whether the interface fits its slot
feat(widget): add the expansion seam and its viewport surface
feat(ui): add the compact card and the rows it previews
feat(widget): render the compact form in a slot that cannot hold the …
fix(ui): keep focus and the overlay where a browser says they go
docs(embedding): describe the compact form and what a host must avoid
docs(ui): correct what the surface claims Radix gives it
refactor(widget): fix three findings from the review pass
32 remaining items
docs: record the compact form where the repo's rules live
fix(widget): stop the overlay locking a visitor out of the host page
fix(widget): tell the host the true thing about a slot that cannot fit
fix(ui): honour the geolocation dismissal, and survive a feed the car…
docs: Escape works now, and say what the floors actually measure
feat(ui): size the compact card to what the host's box can hold
refactor(widget): ask one question about the slot instead of three
feat(widget): make the compact card work in an iframe
fix: triage the second review pass
docs: record what the #161 session learned, and make the browser chec…
fix: triage the code-review pass, including a false claim in my own rule
feat(widget): one slot question, and a compact card that works in an …
feat(map): let map mode be contained by an element, not only the view…
refactor(map): apply the simplify pass