Repository navigation
Description
Summary
The component library has drifted: several "organisms" bundle presentation + data + domain logic + dialog chrome into one unit (EventPanel, EventDetails, EventRegistration, EventShare), a few atoms carry molecule/organism-level responsibility (Panel, Fallbacks, LanguageSelector, ThemeSwitch), and 5 stories' Ladle group no longer matches their folder tier.
This is a sweeping, high-risk restructuring that changes component structure without changing the visual result for the user — the only intentional visual addition is a mailing-list consent checkbox on the registration form. The goal: generic, presentational components that take parsed data from their parents; a single reusable dialog/trigger pattern; and a Ladle taxonomy where folder tier == story label. Radix UI throughout.
Packaging: one tracking issue with an ordered, phased checklist. Each phase is a self-contained commit on one branch; batch CI per the 3-phase PR workflow.
Hard constraint — visual parity. Every existing surface must render pixel-identically before/after (Ladle + Playwright screenshot diff). The consent checkbox is the sole exception.
Proposed changes (phased)
Phase A — Switch → Checkbox with two appearances (atoms; unblocks consent)
- Add dependency
@radix-ui/react-checkbox. - Rename
atoms/Switch/→atoms/Checkbox/(Checkbox.tsx,index.ts,Checkbox.stories.tsx);SwitchProps→CheckboxProps. - Add
appearance: 'switch' | 'checkbox'(default'switch'so the existing look is the fallback).switchkeeps today's@radix-ui/react-switchtrack/thumb (role="switch");checkboxrenders@radix-ui/react-checkboxwith a check indicator (role="checkbox"). Preservecolor/sizevariants + optional trailingchildrenlabel. - Atoms barrel:
Switch→Checkbox,SwitchProps→CheckboxProps. - Migrate the one consumer —
molecules/SearchBar/SearchBar.tsx:94— to<Checkbox appearance="switch" …/>(must stay pixel-identical to the current toggle). - Story shows both appearances.
Phase B — Trigger-based Modal API (atoms; unblocks share + registration dialogs)
- Extend
atoms/Modal/Modal.tsx: add optionaltrigger?: ReactNoderendered viaDialog.Trigger asChild; makeisOpen/onOpenChangeoptional (uncontrolled when omitted, controlled when supplied — backward compatible). Add aModalCloseexport (Dialog.Close asChild) for close-from-inside buttons. - This is the single dialog abstraction reused by Phases E and F.
Phase C — EventPanel → EventView + extract generic DetailRow (organisms/molecules)
- Rename
organisms/EventPanel/→organisms/EventView/(EventView,EventViewProps; story "Event View" under Organisms). Keep it out of the organisms barrel (still lazy-loaded — the code-split rationale is unchanged). - Promote the private
EventDetailrow (inEventDetails.tsx:189) to a genericmolecules/DetailRow/(icon-slotchildren+title+content+url?+isExternal?). Export from molecules barrel; addDetailRow.stories.tsx(Molecules). - Move
EventContactDetails/EventTimingDetails/EventLocationDetailsand thedetectPlatform/directionsUrlhelpers into theEventView/folder as private subcomponents;EventViewowns the ordering rule (contact-highlighted-first when no upcoming date; else timing → location → contact). - Delete
organisms/EventDetails/(folder + story).EventViewcomposesDetailRows directly. pages/event.tsx: update the lazy import to@/components/organisms/EventView(m.EventView). Do not rename the page-localEventPanelwrapper function or the other page-local*Panelwrappers.
Phase D — EventImages → generic ImageCarousel; delete Lightbox atom (molecules/atoms)
- Rename
molecules/EventImages/→molecules/ImageCarousel/. New generic prop:slides: { src: string; alt?: string; caption?: string }[](returnsnullwhen empty). Preserve the Swiper config exactly (autoplay 4000/enabledon >1, loop, EffectFade, dynamic bullets). - Fold
yet-another-react-lightboxdirectly intoImageCarousel, behind aReact.lazy/dynamic boundary so the YARL chunk + CSS stay out of the main bundle (preserve today's behavior). Deleteatoms/Lightbox/(folder + atoms-barrel export + story). Reproduce the current plugin set + single-slide arrow handling. EventViewmapsevent.images→ slides ({ src: img.url, alt: img.alt ?? undefined, caption: img.alt ?? undefined }); theslides.ts/imagesToSlidesmapping moves up intoEventView.- Molecules barrel:
EventImages→ImageCarousel; rename story (Molecules).
Phase E — EventRegistration → generic RegistrationForm + consent (organisms)
- Rename
organisms/EventRegistration/→organisms/RegistrationForm/. ExportRegistrationForm= form only, props{ eventId, upcomingDates, questions, isOnline, eventTitle, eventUrl, onClose? }. It ownsuseForm+ thecreateRegistrationmutation + submitted/thank-you state + errorAlert+ online-noticeAlert+ footer buttons (viaModalClose/onClose), renderingModalHeader/ModalBody/ModalFootercontent. Keep it out of the organisms barrel. - Move the external-vs-native decision, the trigger
Button, and theupcomingDates/enabledQuestions(event)derivation up intoEventView: external →Buttonas link (no dialog); native (upcomingDates.length > 0) →<Modal trigger={<Button>Register</Button>}><RegistrationForm …/></Modal>. DeleteRegistrationButton. - Consent checkbox (new, intentional): add
<Checkbox appearance="checkbox">before the privacy-policy note, default unchecked (opt-in). New fieldsubscribe: z.boolean().optional()insrc/types/registration.ts; send it inconfig/api/mutate.tscreateRegistrationbody. Label from a new i18n keyregistration.mailing_list_consentadded to everypublic/locales/<lng>/events.json(en, fr, …). - Simplification to verify: Radix unmounts
Dialog.Contenton close, soRegistrationFormshould reset naturally on reopen — the current manual reset-on-close dance may be removable. - Rename story → "Registration Form" (Organisms); show the form inside a
Modal, native + external, with consent. - Dependency: companion backend ticket on
sydevs/SahajCloudto accept the consent flag onPOST /events/:id/register(setmailingListSubscribedAt). The widget sends the field regardless; backend ignores it until shipped. (Linked below.)
Phase F — Remove ShareButton/ShareModal; parent composes ShareContent (molecules)
- Delete
ShareButton+ privateShareModal; keepShareContent(+ privateCopyField). Rename folderEventShare/→ShareContent/and story → "Share Content" (folder = primary export). - Molecules barrel: drop
ShareButton/ShareButtonProps; keepShareContent/ShareContentProps. EventViewrenders the share trigger +<Modal trigger={<Button>Share</Button>}>with the "Invite Friend" header +<ShareContent label={event.title} url={event.webUrl}/>— reproduce today's dialog exactly.RegistrationForm's thank-you keeps usingShareContent.
Phase G — Fold LanguageSelector + ThemeSwitch into Navbar (molecules/atoms)
- Move
atoms/LanguageSelector/andatoms/ThemeSwitch/intomolecules/Navbar/as private files;Navbarimports them locally. Remove their stories and their atoms-barrel exports. (Navbar is the only consumer — confirmed.)
Phase H — Card renames + "Molecules / List" group (molecules)
molecules/ListItem/→molecules/RegionCard/(RegionCard,RegionCardProps). Update molecules barrel + usages inpages/index.tsx,pages/country.tsx,pages/region.tsx.molecules/EventItem/→molecules/EventCard/(EventCard,EventCardProps). Update molecules barrel + usage inorganisms/EventsList/EventsList.tsx.- Story titles for
List,RegionCard,EventCard→Molecules / List.
Phase I — Move Fallbacks + Panel to molecules (resolves the tier inversion)
- Move
atoms/Fallbacks/→molecules/Fallbacks/andatoms/Panel/→molecules/Panel/(Panel imports Fallbacks, so both move together to avoid an atom→molecule dependency). Update barrels + all importers (import { Panel } from '@/components/atoms'→'@/components/molecules'across the ~6 pages;Fallbacksimporters:Panel,App.tsx). Story titles → Molecules.
Phase J — Story-taxonomy sweep + docs + Select barrel (cleanup)
- Fix remaining folder≠label:
Map,MapSearchstories → Organisms;SearchBarstory → Molecules. After this, folder tier == story label for every story. - Export
Select,SelectItem,SelectProps,SelectItemPropsfrom the atoms barrel. - Docs:
STORYBOOK.md— permitTier / Groupnested titles (document Molecules / List).DESIGN_SYSTEM.md— refresh the barrel/exception list (remove Switch/Lightbox/LanguageSelector/ThemeSwitch atom entries; add Checkbox, DetailRow, ImageCarousel, RegionCard, EventCard, RegistrationForm, EventView; note Panel/Fallbacks are now molecules; EventShare → ShareContent-only; document the ModaltriggerAPI).
Cross-cutting
- Rename/adjust co-located
*.test.tsx+*.stories.tsxalongside each moved/renamed component; fix all imports. - Reuse existing helpers —
src/lib/shape/(isOnline,nextOccurrence,eventTimeZone,lexicalToHtml),src/lib/events.ts(isSoon) — don't re-implement.
Acceptance criteria
-
Switchrenamed toCheckboxwithappearance: 'switch' | 'checkbox'; SearchBar toggle is visually unchanged; consent usesrole="checkbox". -
Modalsupports atriggerprop (uncontrolled) while remaining backward-compatible with controlledisOpen; both Share and Registration dialogs use it. -
EventPanelrenamed toEventView; genericDetailRowmolecule exists;EventDetailsdeleted; the three detail rows + ordering live inEventView; the rendered event panel is pixel-identical (in-person / online / no-images). -
EventImages→ genericImageCarouseltaking{src, alt?, caption?}[];atoms/Lightboxdeleted; YARL still lazy-loaded (not in the main chunk — verify build output); carousel + lightbox behavior unchanged. -
RegistrationFormis form-only and config-driven;EventViewowns the trigger, external-link case, andModalwrapper; registration flow (native + external + thank-you/share) unchanged. - Consent checkbox present, default unchecked;
subscribeinRegistrationSchema+ sent in the register body;registration.mailing_list_consentadded to all locales; companionsydevs/SahajCloudticket filed & linked. -
ShareButton/ShareModalremoved;ShareContentcomposed into aModalbyEventViewand reused by the thank-you screen; share dialog unchanged. -
LanguageSelector+ThemeSwitchare private Navbar subcomponents; their stories + atoms-barrel exports removed; Navbar unchanged. -
ListItem→RegionCard,EventItem→EventCard; all usages updated;List/RegionCard/EventCardstories grouped underMolecules / List. -
Fallbacks+Panelmoved to molecules with all imports updated; no atom→molecule dependency remains. - Every story's folder tier == its Ladle label;
Select/SelectItemexported from atoms barrel;STORYBOOK.md+DESIGN_SYSTEM.mdupdated. -
pnpm typecheck && pnpm lint && pnpm test:run && pnpm build && pnpm ladle:buildall pass; Playwright before/after shows no visual diff except the consent checkbox.
Files affected (representative)
- Atoms:
Switch/→Checkbox/,Modal/Modal.tsx,Lightbox/(delete),Panel/→molecules,Fallbacks/→molecules,LanguageSelector/+ThemeSwitch/→Navbar,Select/index.ts+ atoms barrel,atoms/index.ts. - Molecules:
EventImages/→ImageCarousel/,EventShare/→ShareContent/,ListItem/→RegionCard/,EventItem/→EventCard/,DetailRow/(new),Navbar/,SearchBar/SearchBar.tsx,List/*.stories,molecules/index.ts. - Organisms:
EventPanel/→EventView/,EventDetails/(delete),EventRegistration/→RegistrationForm/,EventsList/EventsList.tsx,Mapbox/*.stories,organisms/index.ts(NOTE comment). - Other:
pages/event.tsx,pages/{index,country,region}.tsx(+ Panel importers),src/types/registration.ts,config/api/mutate.ts,public/locales/*/events.json,STORYBOOK.md,DESIGN_SYSTEM.md,package.json.
Verification
pnpm typecheck && pnpm lint && pnpm test:run && pnpm build && pnpm ladle:build.pnpm build— confirm YARL is still in a separate lazy chunk (grep thedist/chunk manifest), not the main bundle.pnpm ladle— eyeball Checkbox (both appearances), DetailRow, ImageCarousel, RegionCard/EventCard under Molecules / List, RegistrationForm-in-Modal, ShareContent-in-Modal, Navbar.pnpm dev+ Playwright MCP on a real event: open an event panel (in-person, online, no-images), the registration dialog (native + external), and the share dialog; screenshot and diff againstmain— expect no change except the consent checkbox. Toggle the SearchBar filter (must look identical). Submit a registration with consent checked and confirm the payload includessubscribe.
References
- Rules:
.claude/rules/components.md,code-style.md,tests.md,data-layer.md,i18n-and-state.md;DESIGN_SYSTEM.md,STORYBOOK.md. - Reuse:
src/lib/shape/,src/lib/events.ts,atoms/Modal,atoms/Button,atoms/Select,atoms/Alert,molecules/ShareContent.
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Activity
Ardnived commentedon Jul 1, 2026
Backend dependency (Phase E consent): sydevs/SahajCloud#524 — accept the
subscribeflag onPOST /api/events/:id/registerand persistmailingListSubscribedAt. The widget sends the field regardless; consent isn't recorded until that lands.feat(molecules): give DetailRow a first-class `highlighted` variant
docs(stories): demonstrate Panel's Suspense/error fallbacks
docs(stories): show EventView unadorned (no faux panel border)
style(mapbox): theme the geocoder with brand tokens
refactor(molecules): let DetailRow own its slot tone; memoize EventVi…
refactor(components): genericize event panel family + card/story clea…