Repository navigation
feat(widget): container-aware responsiveness for embeds - #146
Merged
Merged
Conversation
Every responsive decision keyed off the screen, so a 320px column embed on a desktop viewport got the desktop interaction model — a left panel with no drag handle and no swipe dismiss, and no sticky register bar. `useIsWide` observes the widget's own box and falls back to the viewport when there is nothing to measure, which is a strict generalization: in map mode the widget IS the viewport (fixed-inset canvas, fixed drawers, `display: contents` root), so map-mode embeds get exactly the answer they got before. - responsive.ts rewritten: one `WIDE_MIN_PX`, the dead xs/sm/xl entries and the generic `useBreakpoint` gone. First measurement commits pre-paint; only later changes are damped, since vaul's `direction` is not hot-swappable. - Contact moves to `useCoarsePointer`, not width: narrowing a desktop window has never given it a dialer. - Map camera padding stays viewport-derived, and says why — a map only exists where the widget spans the viewport. - Map mode in a boxed slot is now audible (`lib/embed-slot.ts`) instead of silently painting over the host's page. - `responsive.test.ts` pins the decision table: a fourth viewport caller turns the lane red. Closes #107 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The durable half of #107. Per behaviour: container, viewport or input, with the reason each one is right — and `responsive.test.ts` asserts the viewport list so the table cannot quietly stop being true. Also records two things that were measured rather than assumed: - `mode="filled"` really does cancel the anchored geometry (at a 1440px viewport a filled drawer computes to `position: absolute`, `max-width: none`, and fills its box), which is what makes "no CSS-side container-query case exists" a finding rather than a hope. - `container-type: inline-size` does NOT make an element a containing block for `position: fixed` descendants — the widely repeated claim this rule was first written on. Chrome 151 re-parents for `contain: layout` and `transform` and not for `container-type`. The false reason is replaced by the true one, and the correction is kept so it is not re-derived. README gains a host-facing sizing section: map mode needs a full-page slot, `map="false"` fills whatever box you give it and adapts to that box. Closes #107 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas-design with
|
| Latest commit: |
a8a276a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2907b4d8.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://feat-container-responsive.sahajatlas-design.pages.dev |
Deploying sahajatlas with
|
| Latest commit: |
a8a276a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2029d5eb.sahajatlas.pages.dev |
| Branch Preview URL: | https://feat-container-responsive.sahajatlas.pages.dev |
Three fixes from review, plus the CI break my own spec caught. - `Widget.tsx` reads four properties of a DOM we do not own to produce a console line, and did it unguarded. A host that has patched `getBoundingClientRect` — consent wrappers and page builders do — would have thrown from a mount effect straight into RootBoundary, tearing down a widget that had already rendered. Guarded like `claimFragment` beside it. - `useIsWide` seeded from `getBoundingClientRect().width` (the TRANSFORMED box) and then observed `borderBoxSize` (the untransformed one), so under a scaled ancestor it read one width at mount and another on the first resize. Seeds from `offsetWidth` now, which is the box the observer reports — and the right answer anyway, since a scaled widget still lays itself out in its own pixels. - The decision-table scans now strip comments, because documenting the rule was breaking it: "resize past the 768px crossing" in a story docblock reddened the lane as a second hardcoded crossing. The story's visible description keeps the number by interpolating `WIDE_MIN_PX`, so it cannot drift either. - `embed-slot.test.ts` no longer claims the thresholds are slack enough that no normal page trips them; 0.6 does fire for a centred article column, and that is a correct warning rather than a false positive. Closes #107 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Code-review findings. The first is the one the browser pass missed.
- A narrow map-less embed got a bottom sheet that was drag-dismissible with NO
drag handle. The atom's default is `direction === 'bottom' && mode !==
'filled'`, which was right while `filled` could only be the wide left panel;
container-awareness makes it a bottom sheet, and the default then hid the
affordance while leaving the behaviour — plus the README promised a handle
that never rendered. DrawerStack passes `handle` explicitly now, keyed on
dismissibility so the map-less root still shows none.
Worth recording HOW this got through: the Ladle story had to force
`handle={!isWide}` to demo it, so the browser pass verified the story rather
than the app. A story that props its way into a state is not covering it.
- `EventView`'s comment claimed a fix it does not deliver. The sticky bar is
gated on `hasMap` and map mode has no container, so that line computes what it
always did. Corrected in the code, the spec and the rules table.
- The closed list was bypassable by the cheapest route: it grepped one
identifier, so `useMediaQuery({ query: '(min-width: 48rem)' })` satisfied both
it and the `768px` check. The set of files importing react-responsive is now
pinned too, and the container check is call-shaped.
- Smaller: no discarded damper per consumer; the story keys its drawer on
direction (vaul's is not hot-swappable); a duplicate embed-slot case became a
real one; path separators normalised.
Closes #107
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived
added a commit
that referenced
this pull request
Aug 11, 2026
Two conflicts, both from #146 editing the very sections this branch moved. README.md — #146 enriched the inline sizing section with #107's container-responsive behaviour; this branch had replaced that block with a pointer to docs/embedding.md. Kept the pointer, and ported #146's new facts INTO the guide's own "Sizing the element" section rather than dropping them: map-less now adapts to the element rather than the viewport, touch affordances deliberately follow the device instead, and map mode warns in the console when it is given a slot it cannot use. demo.html — #146 added the full-page-slot warning to the same comment where this branch replaced the dead API key with a placeholder. Kept both: the warning reads first, then the key instruction. The 1cf076ab literal stays gone; SahajCloud answers 403 to it, so restoring it would put the harness back to looking broken for a reason unrelated to the code under test. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #107.
Every responsive decision in the widget keyed off the viewport, so a 320px column embed on a desktop screen got the desktop interaction model — a left panel with no drag handle and no swipe-dismiss. This makes the widget adapt to its own box.
What actually changes behaviourally
Stated precisely up front, because the scope is narrower than the ticket's symptom list:
map="false"embed narrower than 768px now gets the bottom-sheet model — drag handle, swipe-dismiss, sheet chrome — instead of the left panel, whatever the viewport is. This is the fix.tel:on touch devices and a copyable number everywhere else, in all modes, replacing a width proxy that mislabelled every touchscreen laptop.And, deliberately, nothing else — see "no behaviour change in map mode" below. In particular the sticky Register bar is unchanged: it is gated on
hasMap, and in map mode the new signal returns the old answer, so that line computes identically before and after. The ticket lists it as a narrow-embed symptom; it is really a map-mode-only affordance, and introducing it map-less would be a separate change (it rides--sy-sheet-top, which is only mirrored in map mode).The finding that shaped the rest
In map mode the widget has no container, by construction. The theme root is
display: contents, the canvas isposition: fixed; inset: 0, and every drawer, peek strip and the cog arefixed— so<sahaj-atlas>has no box and the widget occupies the viewport whatever slot it was given. Inmap="false"the host sizes the element and the widget fills it.So the container signal is a strict generalization, not a behaviour change: where a container exists it wins; where none does,
useIsWidefalls through to the viewport and returns exactly whatuseIsDesktopreturned.DrawerStackonly ever hands it an element in the map-less branch, so no map-mode embed behaves differently after this PR — in map mode "narrow" means a narrow viewport, i.e. a phone, which already got the sheet.The decision table
Required output of the ticket. It lives in
.claude/rules/components.md, andsrc/config/responsive.test.tsasserts the viewport call sites as a closed list, so it cannot quietly stop being true.handleOnly· snap ladderEventView)hasMap-gated, so unchanged today.)tel:vs number + copy popoveruseCoarsePointer)tel:reaches a dialer is hardware.lg:inset-y-4,max-w-[calc(100vw-2rem)]), cog offsetfilledcancels them all map-less.EventHeadermd:pt-4,ListItemlg:h-9Where I disagreed with the ticket. It lists "the desktop contact popover instead of
tel:" as a symptom of the narrow-embed bug. It isn't — a 320px column on a desktop still can't dial, sotel:there would be a new dead end. The ticket's own body anticipates this and its AC allows "the explicitly decided equivalent", so contact moved to(hover: none) and (pointer: coarse).Map mode in a non-full-page slot — decided: full-page is a requirement
Not contained, and not for want of effort: vaul computes a snap sheet's translate from the WINDOW height (the Drawer atom already documents this), so a contained sheet is pushed off-screen by the library's own arithmetic;
--sy-sheet-topis a viewport-relative measurement; the whole drawer layer isfixed. Containing it is a rewrite of the drawer layer, not afixed→absoluteswap.So it is documented (README,
App.tsx,demo.html, the rule) — and, past what the AC asked, detectable:lib/embed-slot.ts+ a mount effect inWidget.tsxwarn via the existingreportIntegrationWarning(console only, no telemetry) when map mode lands in a narrow column or on an element the host gave a height. Slack thresholds — a false positive lands in a stranger's console.This is the call worth overruling if you disagree; it is a product decision about what map-mode embedding is for.
No
@tailwindcss/container-queriestailwind.config.jsis untouched — no CSS-side case exists. Every layout-critical variant is map-mode-only (viewport == container) or cancelled byfilled, which I measured rather than assumed.A correction worth keeping. I first justified rejecting the plugin with the widely repeated claim that
container-type: inline-sizemakes an element a containing block forposition: fixeddescendants. It's false, and I only caught it by testing. Chrome 151:container-type: inline-size/sizecontain: layout/transformThe false reason was replaced by the true one, and the correction is kept in the rule so it isn't re-derived.
Review
Both passes ran. Security review: no critical or high findings —
reportIntegrationWarningconfirmed console-only, nothing host-derived reaches the network/storage/Sentry, the ResizeObserver disconnects and cannot feedback-loop. Two taken: the slot probe read the host's DOM unguarded (a host that has patchedgetBoundingClientRectwould have thrown from a mount effect intoRootBoundary, tearing down an already-rendered widget — a diagnostic breaking what it diagnoses), and the seed/observer measured different boxes (getBoundingClientRectis transformed,borderBoxSizeisn't), so a scaled ancestor would flip the model on the first unrelated resize.Code review cleared the four risk areas (no stuck state or loop in
useIsWide; provider placement correct — portals preserve context; the probe reads the right element, confirmed by measuring a real<sahaj-atlas>in Chrome; the first-render vaul remount is real but flushes before paint and is focus-safe). Findings taken:Drawer's default isdirection === 'bottom' && mode !== 'filled'and map-less is alwaysfilled, so a narrow embed got a handle-less sheet that was still drag-dismissible: an invisible affordance, and a false claim in the README. The tell was in my own story, which had to forcehandle={!isWide}to demo it — I verified the story, not the app.DrawerStacknow passeshandleexplicitly, keyed on dismissibility so the map-less root still shows none.EventView's comment claimed a fix it does not deliver — corrected in code, spec and table (see "What actually changes").useMediaQuery({ query: '(min-width: 48rem)' })satisfied both it and the768pxcheck. The set of files importingreact-responsiveis now pinned too.direction; a duplicateembed-slotcase became a real one; path separators normalised.Nothing dismissed outright. One nit noted rather than solved:
stripCommentsalso strips inside string literals.Verified in the browser (Ladle + Playwright)
The dev backend was down, so there is no data-backed testing here. Ladle needs none, and the new
Drawer — container widthstory exercises the measured path. All by computed style / DOM attribute, never class names.At a 1440px viewport, two boxes on one page:
data-vaul-drawer-directionbottomleftleftat 120ms (inside the 200ms window), commits tobottom+ handle by ~420ms.filleddrawer renders a handle, which is what theDrawerStackfix relies on.DrawerStack's own wiring of it is in the unverified list below.filledcancels the anchored geometry: both compute toposition: absolute,max-width: none,border-radius: 0, filling the box to the pixel.Gates: lint, typecheck,
test:run(1011 tests), build,size,ladle:buildall pass locally. Bundle 370.2 / 372.3 KiB against 395 (24.8 / 22.7 spare) — under 1 KiB added, budget untouched.Needs a check once the backend is back
containeris null there), but it is the default mode and the argument above is structural rather than observed.DrawerStackmap-less — specifically the first-render remount:containeris null on the first render, so<Drawer key={direction}>may mount and immediately remount a vaul root. It happens before paint, but has not been observed.EventActionscontact on an actual touch device.Deliberately not changed
LEFT_DRAWER_PX/--sy-drawer-w: the ticket calls this duplication "with no link", but that is stale —use-map-controller.test.tsalready discovers every fallback and fails on drift. Resolving it again at runtime would re-introduce the DOM read in the map's hot path that the existing comment argues against.Report:
.claude/reports/107-container-responsive.md.🤖 Generated with Claude Code