Skip to content

feat(components): add ladle previews + standardize component library - #6

Merged
Ardnived merged 12 commits into
mainfrom
feat/ladle-component-library
Jun 18, 2026
Merged

Ardnived merged 12 commits into
mainfrom
feat/ladle-component-library

Conversation

@Ardnived

Copy link
Copy Markdown
Contributor

Summary

Implements #5 — introduces Ladle for isolated component
previews and standardizes the component library around an atomic-design
taxonomy, mirroring the WeMeditateWeb methodology adapted to our NextUI + Mapbox
stack. NextUI v2 stays the primitive layer — this adds structure and
previews
, with no visual redesign and no NextUI component rewritten/removed.

Built in reviewable commits (one per phase). lint, typecheck, build, and
ladle:build are all green; ran /simplify and a /code-review subagent pass
before opening.

What's in here (by phase)

  • Ladle harness — @ladle/[email protected] (the Vite 5–era release; Ladle 5 bundles
    Vite 6), .ladle/{config.mjs,vite.config.ts,i18n.ts,components.tsx}, and
    ladle / ladle:build scripts. The global decorator mirrors src/providers.tsx
    (NextUI + React Query + Helmet) and adds a MemoryRouter + an <I18nextProvider>
    with bundled en/fr resources (the app loads locales over HTTP; Ladle has no
    backend). Ladle's theme toggle is mapped onto the dark/light class so every
    story renders in both themes.
  • Atomic reorg — every component moved (via git mv, history preserved) into
    src/components/{atoms,molecules,organisms}/ with a barrel index.ts per tier;
    the cohesive icons/ (→ atoms/icons) and mapbox/ (→ organisms/mapbox)
    sub-modules stay intact. Kebab-case filenames; @/* imports.
  • Exports & typing — standardized on named exports everywhere (dropped
    every export default); app code imports from the tier barrels, while
    intra-components imports use direct file paths to avoid barrel cycles.
  • tailwind-variants — chip.tsx now drives its content styling with tv()
    (the documented reference implementation).
  • Stories — a co-located *.stories.tsx for every atom, molecule, and non-map
    organism (25 files) using native Ladle args/controls, plus src/mocks/events.ts
    fixtures typed against the zod schemas. Map organisms get light, token-gated
    stories.
  • Docs — DESIGN_SYSTEM.md (taxonomy + export/props/tv()/when-to-wrap rules)
    and STORYBOOK.md (story conventions + the deferred WeMeditate helper-migration
    plan). .claude/rules/components.md (and the stale paths in mapbox.md,
    code-style.md, CLAUDE.md) now point at them.
  • CI — pnpm ladle:build added to the gate so broken stories fail the build;
    tsconfig includes .ladle so the harness is type-checked too.

Acceptance criteria

  • @ladle/react added; pnpm ladle serves and pnpm ladle:build succeeds.
  • .ladle/{config.mjs,vite.config.ts,components.tsx} exist; the decorator
    renders components with NextUI + i18n + React Query + Helmet + global styles.
  • Components reorganized into the documented atomic taxonomy with a barrel per
    level; kebab-case filenames; @/* imports; build + typecheck clean.
  • Export style and props typing are consistent and documented; tailwind-variants
    used for the variant-bearing component (chip).
  • A *.stories.tsx exists for every atom and molecule and for non-map
    organisms, using native Ladle controls, viewable in light + dark.
  • DESIGN_SYSTEM.md and STORYBOOK.md committed; .claude/rules/components.md
    references them.
  • No NextUI component rewritten/removed; no intended visual change to the widget.
  • Stories type-checked in CI, and ladle:build gates the workflow.

Notes for review

  • Code-split preserved. The event detail page lazy-loads event-panel, so
    event-panel/event-details/event-registration are intentionally excluded
    from the organisms barrel
    (reached by direct import) — otherwise a barrel
    import would pull them into the main chunk. Verified: App chunk
    1,476 → 1,214 kB, event-panel back in its own ~263 kB lazy chunk.
  • tailwind.config.js shows a large diff: it wasn't Prettier-compliant
    (double quotes), and the repo's format hook normalized it on edit (no
    .prettierignore). Purely quote/whitespace changes — no logic change.
  • Out of scope (noted, not fixed): event-soon.tsx and event-registration.tsx
    have pre-existing Rules-of-Hooks ordering (hooks after an early return null) —
    unchanged by this PR (files only moved), and the new stories don't trigger them.
    Worth a future cleanup. Also, the app's HTTP-backed i18n singleton can still
    initialize transitively in Ladle; stories nonetheless resolve text via the
    isolated bundled-resource instance (its background fetch fails harmlessly).

Manual / visual verification

Run pnpm ladle and browse the tree (Atoms / Molecules / Organisms), toggling
the light/dark theme. Map stories render a "needs token" notice unless
VITE_MAPBOX_ACCESSTOKEN is set in .env.local.

Closes #5

🤖 Generated with Claude Code

Ardnived and others added 9 commits June 18, 2026 12:02
Add @ladle/[email protected] (Vite 5 era, matches our toolchain) with:
- .ladle/config.mjs — story glob, dedicated port, title; points Ladle at
  our own vite.config so the app's multi-entry build doesn't leak in.
- .ladle/vite.config.ts — resolves the `@/` alias to src/ (Ladle relocates
  Vite's root, breaking vite-tsconfig-paths).
- .ladle/i18n.ts — self-contained i18next with bundled en/fr resources, since
  the app loads locales over HTTP and Ladle has no backend.
- .ladle/components.tsx — global decorator mirroring src/providers.tsx
  (NextUI + React Query + Helmet) plus a Router and i18n; maps Ladle's theme
  addon onto the `dark`/`light` class so stories render in both themes.
- ladle / ladle:build scripts; gitignore the build/ output.

Refs #5

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Document the atoms/molecules/organisms/templates classification, the
per-tier barrel + named-export convention, props-typing rules,
tailwind-variants usage, and when-to-wrap-NextUI guidance. This is the
contract the Phase-2 reorg follows.

Refs #5

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Move every component under src/components into atoms/ molecules/ organisms/
per DESIGN_SYSTEM.md, with a barrel index.ts per tier. Keep the cohesive
icons/ (→ atoms/icons) and mapbox/ (→ organisms/mapbox) sub-modules intact.
All moves use git mv so history is preserved; filenames stay kebab-case.

- Standardize on named exports everywhere (drop every `export default`);
  rename SearchBox→MapSearch (avoids @mapbox SearchBox clash) and the
  misspelled EventMetaevent→EventMetadata.
- App code (pages, layouts, App.tsx) imports from the tier barrels; inside
  src/components, components import each other by direct file path to avoid
  barrel import cycles (molecule↔organism) and TDZ bugs.
- Keep event-panel/details/registration out of the organisms barrel so the
  event page's lazy import still code-splits (App chunk 1,476→1,214 kB;
  event-panel back in its own 263 kB chunk).
- Update pages/event.tsx lazy import to map the named EventPanel to default.

No behavioral or visual change; typecheck, lint, and build are green.

Refs #5

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Replace the hard-coded `uppercase font-bold` content class with a tv()
definition exposing an `emphasis` variant (solid|subtle, default solid).
This is the reference tailwind-variants usage promised in DESIGN_SYSTEM.md;
behaviour is unchanged at existing call sites.

Refs #5

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-locate a *.stories.tsx for every atom, molecule, and non-map organism
(25 files) using Ladle's native args/controls; the global decorator's theme
toggle covers light + dark. Map organisms (map, geocoder) get light,
token-gated stories that render a notice without VITE_MAPBOX_ACCESSTOKEN.

- Add src/mocks/events.ts: Event / EventSlim / EventImage fixtures typed
  against the zod-inferred types, with fixed dates for stable previews.
- Event detail organisms (panel/details/registration) import by direct path
  since they're excluded from the organisms barrel.
- Include .ladle in the Tailwind content globs so the decorator's utility
  classes are generated.

pnpm typecheck and pnpm ladle:build are green (25 story chunks).

Refs #5

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add STORYBOOK.md (Ladle wiring, current story conventions, and the deferred
plan to port WeMeditateWeb's StoryWrapper/StorySection/StoryGrid helpers).
Point .claude/rules/components.md at DESIGN_SYSTEM.md + STORYBOOK.md, and fix
stale post-reorg paths in the components/mapbox/code-style rules and CLAUDE.md
(base/event/list → atoms/molecules/organisms; mapbox → organisms/mapbox;
icons → atoms/icons). Document the ladle scripts.

Refs #5

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add `pnpm ladle:build` to the CI gate so broken component stories fail the
build, and extend tsconfig include to `.ladle` so the decorator/config are
type-checked alongside the stories (which already live under src/).

Refs #5

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Share i18next namespaces + %{...} delimiters via src/config/i18n-options.ts
(consumed by the app instance and the Ladle story instance); fix
DESIGN_SYSTEM export-name drift + the props-typing rule; document chip's
emphasis variant; drop a stray search-bar console.log.

Refs #5

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The app's HTTP-backed i18next singleton can still initialize transitively in
Ladle (via components/api importing @/config/i18n); stories nonetheless resolve
text through the isolated bundled-resource instance. Make the comment accurate
(per /code-review) rather than over-claiming the singleton is never touched.

Refs #5

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Deploying atlas-legacy with  Cloudflare Pages  Cloudflare Pages

Latest commit: 16149ba
Status: ✅  Deploy successful!
Preview URL: https://1d348979.syatlas.pages.dev
Branch Preview URL: https://feat-ladle-component-library.syatlas.pages.dev

View logs

Ardnived and others added 3 commits June 18, 2026 16:58
…ateWeb)

Restructure src/components so each component lives in its own PascalCase
folder — <tier>/<Name>/{<Name>.tsx, <Name>.stories.tsx, index.ts} — matching
WeMeditateWeb's layout. Cohesive Icons/ and Mapbox/ sub-modules keep their
grouped files. All moves via git mv (history preserved); intra-component
imports target the component-folder path; tier barrels re-export the folders.

Also ignore build/ (Ladle's output dir) in eslint.config.js — without it,
`eslint .` after a `ladle:build` lints the generated bundles.

Docs updated to the new convention: code-style, DESIGN_SYSTEM, STORYBOOK,
CLAUDE, and the components/mapbox rules. typecheck, lint, build, ladle:build
all green.

Refs #5

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Resolve the export/typing inconsistencies surfaced while mirroring WeMeditate:
- Rename generic component `Props` → `<Component>Props` where there's no
  name clash (Panel, SelectionDropdown, EventItem, ListHeader, ListItem,
  SearchBar, EventsList). Chip keeps `Props` (composes NextUI `ChipProps`).
- Convert useLocale / useMapbox to named exports (use-theme already was), so
  hooks match the named-export convention; update all import sites.
- Document the export-style + props-type conventions in code-style.md.

Refs #5

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Bring our Ladle stories to parity with WeMeditateWeb:
- Port the shared story helpers to src/components/ladle/ (StoryWrapper,
  StorySection, StoryGrid family), adjusting only Tailwind v4→v3
  (bg-linear-to-b → bg-gradient-to-b).
- Rewrite all 25 stories to one consolidated `Default: Story` built from the
  helpers (sections / grids / Minimal-Maximal subsections / inContext Examples,
  trailing <div/>, JSDoc, storyName, category titles) — no more Ladle
  args/argTypes controls or multiple named exports.
- Story canvas is now always light (matching WeMeditate); dark previews are
  shown per-section via <StorySection theme="dark">, which applies the `dark`
  class so NextUI components there render dark.
- Rewrite STORYBOOK.md to the adopted conventions; align .ladle/config.mjs.

typecheck, lint, build, and ladle:build (25 story chunks) all green.

Refs #5

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Ardnived
Ardnived merged commit 87a3c4a into main Jun 18, 2026
3 checks passed
@Ardnived
Ardnived deleted the feat/ladle-component-library branch June 18, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(components): add ladle previews + standardize component library

1 participant