Repository navigation
Description
Summary
Ladle stories force the preview canvas to light and demonstrate dark mode only via per-section <StorySection theme="dark"> blocks, while Ladle's own theme toggle is enabled (.ladle/config.mjs) but unused. Replace that pattern: let Ladle's toggle drive the entire canvas, remove the hardcoded bg-white/dark-surface sections, and fix the components and the useTheme hook so everything — including the Mapbox basemap — renders correctly in both themes from a single theme signal.
Proposed changes
1. Ladle global decorator — .ladle/components.tsx
- Stop force-adding
light/ removingdark. Instead read the active theme from Ladle (useLadleContext().globalState.theme→ThemeState='light' | 'dark' | 'auto') and apply the matching class todocument.documentElement(resolveautoviamatchMedia('(prefers-color-scheme: dark)')). - Replace
<main className="min-h-screen bg-white p-6 text-gray-900">with semantic tokens:bg-background text-foreground. - Drive our theme system from the same Ladle signal (see change 4) so
useThemeconsumers follow.
2. StorySection helper — src/components/ladle/StorySection.tsx
- Remove the
themeprop and everytheme === 'dark'branch (childrenTextColor, dark backgrounds, dark borders, dark scrollable background). - Re-express chrome with NextUI semantic tokens so it's legible in both themes: titles
text-foreground, subsection titlestext-default-600, descriptionstext-default-500, dividersborder-divider, scrollable borderborder-default-200. - Keep
background="neutral" | "gradient"(context backgrounds that simulate the map surface panels float over) but make them theme-aware:neutral→bg-default-100;gradient→ keep the teal gradient (brand, reads on both); scrollable default →bg-background.
3. Stories — remove the dark-surface section (18 files)
- Delete each
<StorySection background="neutral" theme="dark" title="Dark Surface"> … </StorySection>block. Files:atoms/{ThemeSwitch,Panel,Chip,Dropdown,Icons,Fallbacks,LanguageSelector},molecules/{SearchBar,Navbar,EventImages,EventShare,ListItem,List,EventTime,EventSoon,EventItem},organisms/{EventPanel,EventsList}— all*.stories.tsx. - Remove the now-orphaned
text-whiteoverride inatoms/Icons/Icons.stories.tsx:71. - Update story docstrings that reference "dark surface" (e.g.
Chip.stories.tsx's "how chips read on a dark surface").
4. useTheme reactivity (the core gotcha) — src/hooks/use-theme.ts
- Current state: per-component
useStateseeded fromlocalStorage, plus a dependency-lessuseEffect(L41–43) that rewrites the rootlight/darkclass on every render. It is not reactive to externally-set themes and actively fights any class set elsewhere — so the Mapbox basemap (MAP_STYLES[theme],Map.tsx:148) will not follow Ladle's toggle. - Make theme a single reactive source of truth that both NextUI (via the root class) and
useThemeconsumers (Map style) read. Preferred: deriveuseThemefrom the rootdarkclass (observe it) — or back it with a tiny zustand store — and drop the every-render class write. The Ladle decorator then sets that one signal fromglobalState.theme, and the basemap follows. - App behavior unchanged:
ThemeSwitchtoggles the same signal; the standalone widget still persists tolocalStorage.
5. Component dark-mode fixes — audit + convert hardcoded light-only colors
organisms/EventDetails/EventDetails.tsx:text-background bg-primary-100(L84),bg-primary-100(L134),border-primary-100(L192) are tuned for a light surface — verify in dark and adjust withdark:variants or semantic tokens (bg-content2,border-default-200).molecules/EventItem/EventItem.tsx:42andmolecules/ListItem/ListItem.tsx:16: idle bg is transparent and hover already carriesdark:hover:bg-default-100— verify in dark; adjust only if a problem shows.organisms/Mapbox/layers.ts: white cluster text (L21) and#888bounds line (L71) — once change 4 makes the basemap follow the toggle, verify legibility on both basemaps and make them theme-aware (readisDark) if needed.- Sweep remaining
bg-white/text-gray-*/ hardcoded hex acrosssrc/components/**(excluding the intentional brand colors inatoms/Icons/socials.tsx) and convert to semantic tokens ordark:variants.
Acceptance criteria
- No
themeprop remains onStorySection; notheme="dark"/ "Dark Surface" section remains in any*.stories.tsx. -
.ladle/components.tsxno longer hardcodeslightorbg-white; the canvas follows Ladle's theme toggle (light / dark / auto). - Toggling Ladle's theme flips every story — including the Mapbox basemap — between light and dark, with legible text and adequate contrast throughout.
-
StorySectionchrome (titles, descriptions, dividers, neutral/gradient backgrounds) is legible in both themes. - No component renders light-only colors in dark mode; the
EventDetailsprimary-100usages are verified in both themes. -
useThemeno longer rewrites the root class on every render and derives from a single reactive source; standalone-widget dark mode viaThemeSwitchstill works. -
pnpm lint,pnpm typecheck,pnpm test:run,pnpm build, andpnpm ladle:buildall pass.
Files affected
.ladle/components.tsx— decorator reads Ladle theme; drop forced light +bg-whitesrc/components/ladle/StorySection.tsx— dropthemeprop, semantic-token chrome- 18
*.stories.tsxfiles — remove dark-surface sections (list above) src/hooks/use-theme.ts— make reactive, drop per-render class writesrc/components/organisms/EventDetails/EventDetails.tsx—primary-100dark variantssrc/components/organisms/Mapbox/{layers.ts,Map.tsx}— theme-aware layer colors / basemap follows togglesrc/components/molecules/{EventItem,ListItem}/*.tsx— verify hover/idle in dark
References
.claude/rules/components.md,.claude/rules/mapbox.md,.claude/rules/i18n-and-state.mdDESIGN_SYSTEM.md,STORYBOOK.md- Ladle theme API:
@ladle/reactuseLadleContext()→globalState.theme(ThemeState) tailwind.config.js(darkMode: 'class', NextUI light/dark theme tokens)
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Activity
fix(theme): guard localStorage so the toggle survives blocked storage
fix(ladle): keep StorySection gradient text legible in light mode
fix(theme): apply the custom brand palette in dark mode
refactor(ui): unify dark mode across Ladle and components (#20)