Repository navigation
Description
Summary
Introduce ladle for isolated component previews and bring
our component library in line with the methodology used by our sister project
WeMeditateWeb (atomic-design taxonomy, per-component stories, consistent export and
styling conventions, governing docs). Today AtlasReact has ~32 components organized by
domain (base/ event/ list/ mapbox/ icons/) with no way to preview a component in
isolation, no stories, inconsistent exports, and tailwind-variants shipped in deps but
never used. This makes visual review, design QA, and onboarding harder than they should be.
Scope guardrail: we keep NextUI v2 as our primitive layer. This ticket adds
structure and previews around the existing components — it does not rebuild or
replace NextUI-backed components, and is not a visual redesign.
Background / reference
WeMeditateWeb already does this well and is our template:
@ladle/reactwith.ladle/{config.mjs,vite.config.ts,components.tsx}(a global
provider decorator so stories render with app context).components/{atoms,molecules,organisms,templates}/with a folder + barrelindex.ts
per component and co-locatedComponent.stories.tsx.- Governing docs:
DESIGN_SYSTEM.md(atomic classification, tokens, when-to-wrap rules)
andSTORYBOOK.md(story conventions, section ordering, helper API). - Stories use custom
StoryWrapper/StorySection/StoryGridhelpers (documentation-grid
matrices, light/dark, "in context" examples) rather than interactive controls.
We adopt the same shape, adapted to our NextUI + Mapbox stack. Initial stories use
ladle's native controls/args; a follow-up doc (below) plans the optional switch to the
WeMeditate helper style.
Goals
pnpm ladleserves an isolated, navigable preview of every meaningful component.- A documented atomic-design taxonomy and component-authoring conventions for this repo.
- Consistent exports, props typing, barrel exports, and
tailwind-variantsfor variants. - A written migration plan for adopting WeMeditateWeb's story helpers later.
Non-goals
- Rebuilding/replacing NextUI components or any visual redesign.
- Porting the WeMeditate
StoryWrapper/StorySection/StoryGridhelpers now
(planned as a doc; implemented only if we decide to switch). - Adding
jsdom/Testing-Library component tests — that lives in test: establish a testing strategy (local fast tests + CI smoke) #4 (testing strategy).
Proposed changes
Phase 1 — Ladle setup
- Add
@ladle/reacttodevDependencies(pin a version compatible with Vite 5 /
TS 5.6 — verify before choosing). - Add
.ladle/config.mjs: story globsrc/**/*.stories.{tsx,ts},title: "Sahaj Atlas Component Library", a dedicated port. - Add
.ladle/vite.config.tsreusing our@/*alias (vite-tsconfig-paths) and the
Tailwind/NextUI pipeline so stories style identically to the app. - Add
.ladle/components.tsxglobal-provider decorator mirroringsrc/providers.tsx
(NextUIProviders, React QueryQueryClientProvider,HelmetProvider, i18n via
src/config/i18n.ts) and importsrc/styles/globals.css. The widget injects CSS via
JS in production, so stories must import globals explicitly. - Add scripts:
"ladle": "ladle serve","ladle:build": "ladle build".
Phase 2 — Taxonomy & conventions
- Reorganize
src/components/into an atomic taxonomy (atoms/ molecules/ organisms/,
plus treatingsrc/layouts/as templates) while keeping churn reviewable. Draft mapping
(finalize in the doc; keep kebab-case filenames per.claude/rules/code-style.md):- atoms —
icons/*,base/chip,base/dropdown,base/language,base/panel,
base/lightbox-image,base/fallbacks,theme-switch - molecules —
search-bar,navbar,list/{item,header},event/{time,metadata,share,images,soon} - organisms —
mapbox/{map,search},list/events,event/{panel,details,registration}
- atoms —
- Add a barrel
index.tsper level (extend the existingicons/+list/pattern). - Standardize exports (one convention, documented — e.g. named exports for atoms/molecules)
and props typing (consistentinterface/typechoice). - Adopt
tailwind-variants(tv()) for components with size/color/state variants, per
the existing.claude/rules/components.mdguidance (currently unused in the repo). - Write a repo-level
DESIGN_SYSTEM.md(taxonomy + classification + when-to-wrap-NextUI
rules) and update.claude/rules/components.mdto point at it.
Phase 3 — Stories (plain ladle controls first)
- Add a co-located
*.stories.tsxfor each component using ladle's native args/controls. - Cover key variants and both light and dark themes (drive via
useTheme()). - Mock data via existing zod types in
src/types/; gate map/Mapbox stories behind a token
(see risks) and mock React Query / store reads where a story needs them.
Phase 4 — Story-helper migration plan (doc deliverable)
- Add
STORYBOOK.mddescribing how to port WeMeditateWeb'sStoryWrapper/StorySection/
StoryGridhelpers and standard section ordering (Variants → Sizes → States → Examples)
into asrc/components/ladle/folder, and how existing plain-control stories would be
converted. Implementation deferred pending review of the Phase 3 result.
Phase 5 — CI / tooling
- Ensure stories are type-checked (extend
tsconfigincludeor runladle buildin CI). - Optionally add
pnpm ladle:buildto.github/workflows/ci.ymlso broken stories fail
the gate. Coordinate with test: establish a testing strategy (local fast tests + CI smoke) #4 (testing strategy) — ladle gives visual verification that
complements that ticket's node-only tests.
Acceptance criteria
-
@ladle/reactadded;pnpm ladleserves andpnpm ladle:buildsucceeds. -
.ladle/{config.mjs,vite.config.ts,components.tsx}exist; the provider decorator
renders components with NextUI + i18n + React Query + Helmet and global styles. - Components reorganized into the documented atomic taxonomy with a barrel
index.ts
per level; filenames stay kebab-case; imports use@/*; app builds (pnpm build)
and typechecks (pnpm typecheck) clean. - Export style and props typing are consistent and documented;
tailwind-variants
used for at least the variant-bearing components. - A
*.stories.tsxexists for every atom and molecule and for non-map organisms,
using native ladle controls, each covering light + dark themes. -
DESIGN_SYSTEM.md(taxonomy + conventions) andSTORYBOOK.md(helper-migration
plan) are committed;.claude/rules/components.mdreferences them. - No NextUI component is rewritten/removed and there is no intended visual change to
the running widget. - Stories are type-checked in CI (and optionally
ladle:buildgates the workflow).
Assumptions
- Ticket targets
sydevs/AtlasReact; WeMeditateWeb is reference-only. - "Standardize all components / move to a structured system" means the atomic-design +
ladle methodology above — not migrating off NextUI and not a redesign. - Map/Mapbox organisms may get lighter story coverage (token/network constraints).
- Locale JSON loads over HTTP via
VITE_HOST; stories may need a default locale or
bundled strings to render text without a backend.
Risks / open questions
- Provider isolation: components depend on i18n (HTTP-loaded locales), zustand stores,
React Query, andHashRouter. The decorator must supply these; map components also need
VITE_MAPBOX_ACCESSTOKEN. Map stories may need stubs or be marked "needs token". - Reorg churn: moving files changes many import paths; do it in reviewable commits and
rely on@/*+ barrels to limit blast radius. - Ladle + Vite 5 compatibility: confirm a
@ladle/reactversion that supports our
Vite 5 / TS 5.6 toolchain before pinning.
Files affected
package.json—@ladle/reactdevDep +ladle/ladle:buildscripts..ladle/config.mjs,.ladle/vite.config.ts,.ladle/components.tsx— new.src/components/**— atomic reorg, barrelindex.tsper level, co-located*.stories.tsx.src/components/ladle/**— new, only if/when Phase 4 helpers are adopted.DESIGN_SYSTEM.md,STORYBOOK.md— new governing docs..claude/rules/components.md— reference the new docs.tsconfig*.json— include stories for typecheck..github/workflows/ci.yml— optionalladle:buildgate.
References
- WeMeditateWeb:
DESIGN_SYSTEM.md,STORYBOOK.md,.ladle/,components/{atoms,molecules,organisms}/. - This repo:
.claude/rules/components.md,.claude/rules/code-style.md,src/providers.tsx,
src/config/i18n.ts,tailwind.config.js. - Related: test: establish a testing strategy (local fast tests + CI smoke) #4 (testing strategy — ladle complements node-only tests with visual verification).
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Activity
refactor(components): PascalCase folder-per-component (mirror WeMedit…
refactor(components): standardize props-type names + hook exports
refactor(stories): adopt WeMeditateWeb's Ladle story methodology