Skip to content

feat(widget): container-aware responsiveness for embeds #107

Closed

Description

@Ardnived

Summary

Product direction (confirmed):

We need to update to utilize container-aware responsiveness. Embedding is a core behaviour of the project and we need to be able to respond gracefully to all kinds of embeds.

The widget ships as <sahaj-atlas> embedded in arbitrary host layouts, yet zero container queries exist — every responsive decision keys off the viewport (.claude/reports/RELEASE_READINESS.md §5, Appendix C): useBreakpoint/useIsDesktop via react-responsive's useMediaQuery (src/config/responsive.ts:14-25 and :33-45), plus Tailwind md: variants. Consequence: a 320px-wide column embed on a desktop viewport gets desktop behaviour — a left drawer with handleOnly (no drag handle, no swipe dismiss), the desktop contact popover instead of tel:, no sticky register bar. A narrow-column WordPress sidebar embed gets the wrong interaction model.

In map mode it is worse than wrong — it is impossible: the canvas is position: fixed; inset: 0 (src/App.tsx:173-176), so the map takes the whole viewport regardless of the element's size. Map-mode embedding currently REQUIRES a full-page slot, and that is undocumented.

Current state (verified)

  • useIsDesktop() consumers: src/views/DrawerStack/DrawerStack.tsx:180, src/views/EventView/EventView.tsx:53, src/components/molecules/EventActions/EventActions.tsx:74 (lines current on the in-flight feat/classify-errors branch; the readiness report cites 169/47/74 pre-branch).
  • useIsDesktop debounces 200ms for a reason: the drawer direction (left ≥md / bottom below) remounts the drawer wrapper on the md crossing — vaul direction isn't hot-swappable (responsive.ts:27-31 docblock). Any container-based signal needs the same damping.
  • LEFT_DRAWER_PX = 352 hard-duplicates the --sy-drawer-w CSS default (src/hooks/use-map-controller.tsx:62-66) — a host overriding the variable silently desyncs map camera padding.
  • Dead code: of the five breakpoints entries only md is consumed today (useBreakpoint('md') at use-map-controller.tsx:105, plus useIsDesktop); the report flags xs/sm/xl as dead. Cleanup moves INTO this ticket since it rewrites responsive.ts.
  • tailwind.config.js:243 is plugins: [] today.

Proposed changes (implementer refines)

  • Observe the widget CONTAINER: a ResizeObserver-based useContainerBreakpoint hook replacing viewport useIsDesktop wherever the question is really "how wide is the widget" (drawer chrome, popover-vs-tel:, sticky register bar). Keep the remount-damping behaviour.
  • CSS side: evaluate the @tailwindcss/container-queries plugin for @container variants. Tailwind is pinned 3.4.3 — v4 utilities don't exist here, and an ungenerated class fails silently (lands in the DOM with no CSS behind it) — see .claude/rules/code-style.md. Any new variant must be verified by computed style, not class presence.
  • A documented decision table — required output, not optional: for each responsive behaviour, container-derived vs viewport-derived, with the reason. Some decisions may genuinely stay viewport/device-based (e.g. drawer direction bottom-vs-left may be about the device; touch affordances are about the input, not the slot width).
  • Define map-mode behaviour in a non-full-page slot — a decision is required in this ticket either way: contain the canvas to the element instead of fixed-inset, OR document full-page as a hard requirement in the host-facing docs.
  • Opportunistic (same file region): unify LEFT_DRAWER_PX with --sy-drawer-w if it falls out of the container work naturally.

Honest sizing: this is the largest ticket of the wave. It touches DrawerStack/EventView/EventActions regions that sibling tickets also touch — plan for it to merge last and rebase over siblings (this repo squash-merges; see the stacked-PR guidance in CLAUDE.md).

Acceptance criteria

  • A narrow (≤400px-wide) column embed on a desktop viewport gets the narrow interaction model per the decision table (drag/dismiss affordances, tel: contact, sticky register bar — or the explicitly decided equivalent).
  • The decision table (container-derived vs viewport-derived, per behaviour, with reasons) exists in the code/docs and is reproduced in the implementation report.
  • Map mode in a non-full-page slot: either the canvas is contained to the element (no longer position: fixed; inset: 0), or full-page is documented as a requirement in host-facing docs — the decision is stated.
  • src/config/responsive.ts is rewritten; dead breakpoint entries are removed.
  • If @tailwindcss/container-queries is adopted, the plugin is added additively to tailwind.config.js, and every new variant is verified generated via computed style.
  • No regression at real mobile sizes: snap-point ladder, drag-tracking chrome, and swipe dismiss still work.
  • Lint + typecheck + pnpm test:run pass.
  • Verified in the running widget in at least three shapes: full-page desktop, real mobile viewport, and a narrow column embed on a desktop viewport (via demo.html or a constrained wrapper).
  • Write an implementation report to .claude/reports/<issue-number>-<short-slug>.md — in the MAIN checkout at /Users/devindra/Documents/Projects/SahajAtlasWeb even when implementing from a worktree (the folder is gitignored) — covering what changed, what was deliberately NOT changed, and which readiness-report findings are resolved.

Files affected

  • src/config/responsive.ts — full rewrite, including dead-breakpoint cleanup
  • A new container-size hook (e.g. src/hooks/use-container-breakpoint.ts)
  • The useIsDesktop call sites' behavioural branches: src/views/DrawerStack/DrawerStack.tsx, src/views/EventView/EventView.tsx, src/components/molecules/EventActions/EventActions.tsx
  • src/App.tsx — map-container region only
  • tailwind.config.js — plugin addition only (additive; a sibling ticket owns the rest of that file)

Parallel implementation: this ticket OWNS the files/regions listed above; sibling release-hardening tickets run concurrently — avoid edits outside owned files except strictly additive ones. This ticket should expect to rebase over siblings at merge time.

References

  • .claude/reports/RELEASE_READINESS.md §5 (Responsiveness — adapts to the viewport, not its container), Appendix C
  • .claude/rules/code-style.md — Tailwind 3.4.3 pin + the silent ungenerated-class trap
  • CLAUDE.md — stacked-PR / squash-merge rebase guidance

Activity

  1. added 2 commits that reference this issue on Aug 11, 2026
    77ace36
    a8a276a
  2. added a commit that references this issue on Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Hold Until

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions