Repository navigation
Description
Summary
Rework the entire Sahaj Atlas UI from the single floating <Panel> + <Modal>
model into a URL-driven nested-drawer navigation system built on Vaul.
Everything other than the map renders as drawers: a non-dismissable root drawer
holding search + the global region list, with nested drawers drilling down
through regions to events, registration, and sharing. On tablet/desktop the
drawers sit on the left (map fills the rest); on mobile they're bottom
sheets with snap-to-peek and swipe-dismiss. Any view can also render
map-less (map=false), so it can be dropped into a host page or iframe as
content-only. The embeddable custom element is renamed <syatlas-map> →
<sahaj-atlas> (mode-agnostic, since it can now render with or without a
map).
The guiding principle (per review): the URL is the single source of truth.
The open drawer stack is a pure function of the current path — no bespoke
history-mirroring store, no stack that can diverge from the URL. This keeps
Back/forward/deep-link/scroll-restoration as the router's job and removes the
largest class of bugs from the design.
Scope also removes SearchBar, Navbar (→ Toolbar), Panel, Modal, and
ListHeader, and renames organisms/EventView → EventDetails. One PR (by
decision); the body is ordered to serve as the review order.
AC-0 (do this first — de-risk Vaul). Prove, as a runnable spike, that Vaul
1.1.2 supports the required combination before building on it:
- nested drawers (
Drawer.NestedRoot) that are non-modal and directional
(leftat ≥md,bottomon mobile), stacked ~4–5 deep, with the map (or,
whenmap=false, the content) staying interactive behind them;- the RootView combo specifically:
modal={false}+dismissible={false}+
snapPoints— and dragging between peek/half/full still works;- portaling drawer content into the widget container (Root
container
prop /overlayContainer()), notdocument.body.If the nested combination doesn't compose, STOP and consult — do not
silently switch approaches. Documented fallback (P3): render one Vaul
Drawer.Rootper breakpoint whose body animates on push/pop (Framer Motion,
already a dep) instead of physically nesting; the URL-driven stack model below is
unchanged either way.
Dependency & foundation
- Add only
vaul, pinned exactly ("vaul": "1.1.2"). Investigation
confirmed vaul standalone exportsNestedRoot/Portal/Contentand Root props
modal/dismissible/direction(top,bottom,left,right)/snapPoints/
container— full feature parity. shadcn's Drawer is the same vaul underneath
(no Radix-native alternative), so it adds nothing here. - No shadcn/ui foundation swap. Keep the existing Radix + tailwind-variants
base. Buildatoms/Drawer/(folder-per-component + story + barrel) on vaul with
tailwind-variantsslots and theoverlayContainer()portal pattern
(src/lib/overlay.ts), matching Modal/Select/Dropdown today. No
components.json, nocn(), no CVA. - White-label untouched. Keep the shipped runtime brand system
(--primary-1..12+buildScale,palette.ts/BrandTheme.tsx, PR feat(ui): white-label brand palette for the embedded widget #23). The
drawer inherits it for free by portaling into the theme root. - Vaul is unmaintained (stable/feature-complete, no future fixes) — accepted
and pinned; revisit only if a real bug surfaces.
The navigation model (URL is the single source of truth)
- Stack = f(pathname). The open drawer stack is derived purely from the
current path. ExtendresolvePath(src/lib/shape/path.ts) to return the
full ancestor chain for any URL (/india/pune/123→
[India, Pune, event 123]), and render one drawer per entry. There is no
drawer-stack store and nouseNavigationTypePUSH/POP interception — the
router's history is the stack, so Back/forward, deep-link, and scroll
restoration all come from the router. - Every navigation is a normal router navigation. Drilling a region, tapping
a map event, opening register/share — all arenavigate(path). A map-click is
navigate(event.webPath)and rebuilds the stack to that event's ancestors (the
stack is always the breadcrumb; it never diverges from the URL). - URL vs. canonical. The address bar reflects wherever the user navigated.
webPath/webUrlare used only as the canonical URL for sharing + SEO —
emitted as<link rel="canonical">+ og:url viareact-helmet-asyncin the
standalone build only, and as the Share target. Remove the current
canonicalization redirects (region.tsx:45,event.tsx:33); legacy URLs
(/events/:id) render in place and simply carry a canonical tag. Nothing
redirects the address bar. - Camera follows the top drawer. The deepest view frames the map (region
bounds / event point); navigating up restores the parent view's camera. Driven
through theMapControllerseam (below), never by views calling the map
directly. - Deep-link cold load naturally reconstructs the full ancestor chain (it's
justresolvePath). Each ancestor view is a normal Suspense query — no
bespoke lazy-reveal machinery. TanStack Query dedupes and the shared
['geojson']feed is fetched once (fetch.ts:86); prefetch on idle only if a
real problem is ever measured. - Home region. RootView (global country list) is always the base. A configured
client.regionis reached by navigating to its path on load (its RegionView
opens over root, exactly like a deep-link); Back returns to the global list.
The Views (src/views/)
src/pages/ is replaced by src/views/. Views are routed units rendered by
a DrawerStack component that maps the resolved ancestor chain → open (nested)
Vaul drawers. Each View is folder-per-component (<Name>/<Name>.tsx +
<Name>.stories.tsx + index.ts) with one maximally-configured story, all
under a new Ladle group "Views".
| View | Route | Header | Body | Drawer config |
|---|---|---|---|---|
| RootView | / |
MapSearch | Global list of country/regions | non-dismissable, non-modal, snap points (mobile) |
| SearchView | /search?q=¢er= |
search field | Ranked events by distance from the geocoded place / map center (nearest-N + online), stable list | non-modal, dismissable |
| RegionView | <region-path> |
Region name (+ back) | One list: child regions first, then child events (plain concatenation, no section headers) | non-modal, dismissable |
| EventView | <event-path> |
none | <EventDetails> (no Panel/Modal wrapper — the drawer is the chrome) |
non-modal, dismissable |
| RegistrationView | <event-path>/register |
"Register for <Event title>" |
Registration form; spinner + result state | non-modal, dismissable |
| ShareView | <event-path>/share |
"Share <Event title>" |
Share content | non-modal, dismissable |
- Only the root drawer is non-dismissable; every other drawer is dismissable,
all are non-modal. - Each View renders a
Toolbarin itsDrawerFooterslot.
Responsive & drawer behavior
- Direction by breakpoint: left at ≥md, bottom on mobile. Vaul
direction
isn't hot-swappable, so remount the drawer wrapper on the md crossing — but
debounce/add hysteresis touseBreakpoint('md')(responsive.ts:13is a
raw media query) so a viewport resting near 768px can't thrash-remount. Because
content is route-driven, a wrapper remount doesn't lose the view; explicitly
hoist in-progress RegistrationView form state (store or URL) so a remount
can't drop a half-filled form, and verify no camera re-fly fires purely from a
remount. - Snap points: mobile RootView only (peek = MapSearch header / half / full).
Desktop-left drawers are fixed-width panels — feed that known width to the
map padding directly (do not DOM-measure#syatlas-main). - Non-modal throughout: the map (or, when
map=false, the content) stays
interactive behind open drawers. - Map padding:
usePaddingStateaccounts for the fixed left-drawer width at
≥md so camera/controls aren't occluded. - Portal: drawers portal into the theme root via
overlayContainer(). - A11y: stacked non-modal drawers need care — verify focus order,
Esc,
and that backgroundaria-hiddenisn't wrongly applied (non-modal must leave the
map reachable). Part of AC-0.
The map seam (MapController)
Put all camera control behind a single context seam so no view branches on the
map flag:
useMapController()exposesframeRegion(...)/frameEvent(...)/
clearSelection()etc. Views call it unconditionally.- When a map is present the provider drives the real map (today's
useMapbox().moveMap/fitBounds/setSelection). - When
map=falsethe provider supplies a no-op controller of the same
interface. - One place knows whether a map exists;
if (hasMap)checks never leak into
views/effects (replaces the guards currently atregion.tsx:51,
event.tsx:38,index.tsx:41).
Map-less rendering (map=false) + the <sahaj-atlas> element
The "does the widget render a map canvas?" axis is a single map flag
(default true) — not an "embed" concept (the widget is always embedded; the
real axis is the map's presence).
- Rename the custom element
<syatlas-map>→<sahaj-atlas>(valid
hyphenated name; mode-agnostic). UpdatecustomElements.define, the vite
styleId,demo.html, and host-embed docs. The standalone#syatlasmount id
stays. - Delivery:
<sahaj-atlas map="false">(attribute; defaulttrue) and
?map=0on the standalone build (iframe-friendly). Both feed one internal
hasMapflag. Default on both surfaces is the full map; content-only is
opt-in. - Map subtree fully omitted when
map=false: noMapProvider, no<Mapbox>,
no Mapbox token required;MapControlleris the no-op implementation. - Base view inline; deeper views are overlay drawers: the targeted view fills
the container as plain inline content (no drawer chrome). Navigating deeper opens
Vaul drawers portaled into the widget container (notdocument.body),
covering the content area. All normal interactions continue. - Any view can render map-less at its route.
- Search when map-less geocodes and shows a nearest + online results list (no
map to animate). - Audit viewport assumptions:
window.scrollTo/scrolllisteners /
100dvh/100dvwfixed layout (event.tsx:28,Map.tsx:131,map.tsx:14,
Panel.tsx:31) assume the widget owns the viewport — false inside a host
container. Scope everywindow/document/dvhassumption to the map build or
make it container-relative.
Component teardown / rework
- Remove
molecules/SearchBar— its MapSearch geocoder moves into RootView/
SearchView headers; itsonlineOnlytoggle folds into SearchView (online events
always included in results). - Remove
molecules/Navbar→ rename tomolecules/Toolbar: no bordered
variant, drop the dead nav links; holdsLanguageSelector+ThemeSwitch+ a
small Sahaj Atlas wordmark/attribution; rendered in every drawer's
DrawerFooterslot. - Remove
molecules/Panel— the drawer is the container. - Remove
atoms/Modal— Registration and Share are drawer routes now; no
centered-dialog usage remains. - Remove
molecules/List/ListHeader(already unused). - Rename
organisms/EventView→organisms/EventDetails(the reusable
content body: carousel, description, timing/contact/location cards). The new
drawerEventViewrenders<EventDetails>. - Delete the dead
useNavigationStatestore (store.ts:41) — confirm nothing
(e.g. analyticspreviousPath) depends on it first. - Keep/re-home
EventsList/DynamicEventsList,EventCard,RegistrationForm,
ShareContent,List,EventDetailsinto the new Views.
Routing & state
resolvePathstays terminal-segment-only for entities (numeric tail →
event; other tail → region) and additionally returns the full ancestor
chain for stack derivation./registerand/shareare explicit React Router routes matched before
the catch-all slug route (not reserved suffixes insideresolvePath). Add
register/shareto a reserved-slug guard so a CMS region can never silently
shadow them.SearchViewowns/search;RootViewowns/. Both build entries stay:
standalonemain(BrowserRouter, hosts?map=0) andwidget
(HashRouter,<sahaj-atlas>).useViewState(camera/selection/boundary) is preserved but driven only via
MapController.useSearchState.onlineOnlyfolds into SearchView.
Analytics / misc
- Fathom pageview fires on every
locationchange (App.tsx:95). With per-drill
navigations this is correct-by-default (each is a real route), but verify no
double-count on map-click orreplacenavigations. - Confirm drawer navigation does not remount
<Mapbox>(reuseMaps+
worldview/languagerecompute on locale,Map.tsx:147) — a layout remount
would reset the map.
Suggested implementation order (single PR)
- AC-0 spike: Vaul non-modal + nested + directional + snap + container
portal, and the exact RootView combo. Consult if it fails. atoms/Drawer/on vaul (tailwind-variants +overlayContainer()).resolvePath→ ancestor chain;DrawerStackderiving drawers from the URL;
MapControllerseam (real + no-op).- The six Views (
src/views/) +Toolbar; renameEventView→EventDetails;
remove SearchBar/Navbar/Panel/Modal/ListHeader; explicit/register/share
routes; remove canonicalization redirects (+ Helmet canonical in standalone). - Map-less mode: rename element to
<sahaj-atlas>,mapattribute +?map=0,
map-subtree omission viaMapControllerno-op, inline base + container-portaled
overlay drawers, viewport-assumption audit. - SearchView (distance-from-place ranking, quantized key); breakpoint hardening;
stories ("Views" group); docs + test updates.
Risks
- Vaul capability — mitigated by AC-0 spike + consult gate; documented
single-drawer fallback (P3). - Vaul unmaintained — pinned; vendored fork remains an option if a bug bites.
- Stacked non-modal a11y — verified in AC-0.
- Breakpoint remount — debounce + hoisted form state.
- Large diff (one PR) — section order = review order.
Acceptance criteria
Navigation & routing
- The open drawer stack is a pure function of the pathname (
resolvePath
returns the full ancestor chain); there is no drawer-stack store and no
PUSH/POP interception. - All navigation is normal router navigation; a map-click is
navigate(event.webPath)and the stack always equals the URL breadcrumb. - Back / forward / swipe-dismiss / scroll-restore behave via the router with
no custom history logic. - Cold-load deep-link renders the full ancestor chain; each ancestor is a
normal Suspense query (no lazy-reveal machinery). - Camera follows the top drawer and restores the parent on navigate-up,
driven only throughMapController. - Configured
client.regionopens as a RegionView over RootView on load. -
…/registerand…/shareare explicit router routes, deep-linkable, and a
CMS region slug can never shadow them. -
resolvePathremains a pure terminal-segment function (unit-tested).
URL / canonical / SEO
- Address bar follows navigation; no canonicalization redirects remain
(residualnavigate(...,{replace})removed); legacy/events/:idrenders. - Share target is always the validated
webUrl(never the live address bar). -
<link rel="canonical">+ og:url are emitted only in the standalone build;
the widget's hash URLs are not advertised as canonical. - Smoke test: a legacy
/events/:idrenders and carries the correct canonical.
Views & components
-
src/views/contains RootView, SearchView, RegionView, EventView,
RegistrationView, ShareView, each drawer-wrappable, each with one
maximally-configured story under the Ladle "Views" group. - RegionView shows child regions then child events in one list (no headers).
- EventView renders
<EventDetails>with no Panel/Modal wrapper (map build). - RootView drawer is non-dismissable + non-modal + snap-pointed (mobile); all
other drawers are dismissable + non-modal. -
SearchBar,Navbar,Panel,Modal,ListHeader, and the dead
useNavigationStateare deleted with no remaining imports;
organisms/EventViewrenamed toEventDetails. -
Toolbar(no bordered variant, no dead nav links) holds Language + Theme +
attribution and renders in every drawer footer.
Responsive & drawer behavior
- Left at ≥md, bottom on mobile; the md hook is debounced so it can't
thrash-remount; RegistrationView form state survives a remount. - Non-modal: map (or, when map-less, the content) stays interactive behind
open drawers;
stacked-drawer focus/Esc/aria-hiddenverified (AC-0). - Map padding uses the known fixed left-drawer width (no DOM measurement).
- Drawers portal into the widget container.
Map-less rendering (map=false)
- The custom element is registered as
<sahaj-atlas>(valid hyphenated name);
customElements.define, vitestyleId,demo.html, and docs updated. -
?map=0(standalone) and<sahaj-atlas map="false">both render map-less;
the default (<sahaj-atlas>/ no?map) renders the full map. - Map-less renders no MapProvider/Mapbox and needs no Mapbox token; the
MapControlleris a no-op and no view branches on themapflag. - Map-less base view renders inline; deeper navigations open drawers that
cover the content area (portaled into the container). - Any view renders map-less at its route; map-less search geocodes to a
results list. -
window/document/100dvhviewport assumptions are scoped so they don't
break inside a host container.
Search & data
- SearchView ranks by distance from the geocoded place / map center (reusing
the quantized lat/lng query key), not the live viewport; the list does not
re-sort on map pan.
Quality
-
MapControlleris the only place that knows about map vs map-less. - Fathom pageviews are not double-counted on map-click / replace navigations.
-
<Mapbox>is not remounted by drawer navigation. -
pnpm lint,pnpm typecheck,pnpm test:run,pnpm build, and
pnpm ladle:buildpass; unit tests updated for renamed/removed components,
resolvePathancestor-chain, and the new routing. - Docs updated:
CLAUDE.md,.claude/rules/components.md,
.claude/rules/mapbox.md,DESIGN_SYSTEM.md,STORYBOOK.md.
Files affected (indicative)
- New:
src/views/**(6 views + stories + barrel),atoms/Drawer/**,
molecules/Toolbar/**,DrawerStack,MapControllercontext/provider. - Renamed:
organisms/EventView→organisms/EventDetails. - Removed:
molecules/SearchBar,molecules/Navbar,molecules/Panel,
atoms/Modal,molecules/List/ListHeader,src/pages/**,src/layouts/*
(folded into DrawerStack + map-less layout), deaduseNavigationState. - Changed:
src/App.tsx,src/Widget.tsx(customElements.define('sahaj-atlas', …)+mapprop),src/main.tsx,vite.config.ts(mapflag +styleId
rename),demo.html+ host-embed docs,src/lib/shape/path.ts(ancestor chain- reserved-slug guard),
src/config/store.ts,src/hooks/use-mapbox.ts(behind
MapController),src/config/responsive.ts(debounced md),src/config/api/*
(geocode search shaping),package.json(add[email protected]).
- reserved-slug guard),
References
- Vaul API — https://vaul.emilkowal.ski/api · repo (unmaintained notice) —
https://github.com/emilkowalski/vaul - Prior art: PR refactor(ui): migrate components from NextUI to Radix UI #24 (NextUI→Radix), feat(ui): white-label brand palette for the embedded widget #23 (white-label palette), refactor(components): genericize event panel family + card/story cleanup #27 (event panel
family), feat(widget): nested region URLs and a unified Region model #29 (nested region URLs / Region model) - Repo rules:
.claude/rules/mapbox.md,components.md,code-style.md,
data-layer.md,i18n-and-state.md,tests.md;DESIGN_SYSTEM.md,
STORYBOOK.md
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Activity
fix(ui): polish drawer nav per review (flags, padding, close, snap po…
feat(ui): rework UI into a nested-drawer navigation system (#31)