Skip to content

refactor(ui): consolidate design-system exports, stories, and props #14

Closed

Description

@Ardnived

Summary

Following the original component-library standardization (#5 / #6) and the Dropdown
unification (#12), the design system (src/components/{atoms,molecules,organisms}/,
24 component folders / 25 Ladle stories) has drifted in three ways: barrels leak
internals via export *, sibling components disagree on prop names, and story titles
carry an ad-hoc second level. This ticket brings SahajAtlas in line with the cleaner
conventions used in the sibling WeMeditateWeb project — explicit named exports
(primary component + Props type only), single-level story titles, and disciplined
prop naming — plus inlining single-use internals and a light visual-consistency pass.

No runtime behavior change. SahajAtlas deliberately uses NextUI primitives
directly
and only wraps when there's app-specific value, so we adopt WeMeditate's
export/story/naming conventions, not its component inventory. The widget is the only
consumer of these props, so the internal renames are safe.

Current behavior

  • Leaky exports. Component and tier barrels use export *, re-exporting
    subcomponents, helpers (isSoon), and internals alongside the primary component.
  • Inconsistent props. Navigation (link vs returnLink), overlay state
    (open/close vs isOpen/onOpenChange), and domain booleans (isOnline vs
    online, convertTimeZone) diverge across sibling components.
  • Story sprawl. Story titles carry an ad-hoc second level (Atoms / Feedback,
    Molecules / Display, …) and a few pure-internal subcomponents have their own folders.

Proposed changes

1. Strict export surface

  • Replace every export * with explicit export { X } from './X' +
    export type { XProps } in all component barrels and the three tier barrels.
  • Extract isSoon() (and the timezone-format helper) into a new src/lib/events.ts
    — a home for pure domain utils, so non-UI consumers can use the predicate without
    importing a component. Update EventsList and EventSoonChip to import from @/lib.
  • Documented multi-export exceptions (the only allowed ones, spelled out in
    DESIGN_SYSTEM.md):
    1. Dropdown compound — export { Dropdown, DropdownItem } + Props.
    2. Icons/ — an icon-set module.
    3. Mapbox/ — sub-module exposing Mapbox + MapSearch (layers/themes stay internal).
    4. EventsList/ — container/presentational pair (DynamicEventsList + EventsList).

2. Inline single-use internals (and drop their previews)

  • EventShare — keep ShareButton as the only export; make ShareModal +
    ShareContent module-private (extract the shared social-link markup into a private
    helper reused by RegistrationModal, or keep one exported ShareContent if cleaner —
    document whichever).
  • EventRegistration — keep RegistrationButton exported; make RegistrationModal +
    RegistrationFields private.
  • EventDetails — inline the generic EventDetail primitive. Preferred: consolidate
    the three cards into a single EventDetails component (<EventDetails event={event} />)
    so the folder has one primary export + one story; if EventPanel's layout interleaves
    the cards, keep them as a documented family instead.
  • TimezoneChip — move out of atoms/Chip/ and inline as a private composition in
    EventTime; the Chip barrel then exports only Chip.

3. Atomic-design ruling — TimezoneChip / EventSoonChip

Neither become Chip variants (that would push tooltip/date logic into a primitive
atom), nor raw <Chip> rebuilt at every call site (duplicated color/icon/copy):

  • Chip stays a pure presentational atom — never any time/date/domain logic.
  • Domain logic → pure helpers in src/lib/ (EventsList sorting needs the isSoon
    predicate, not a Chip).
  • Single-use composition → inline into its one parent (TimezoneChip → EventTime).
  • Multi-use composition → a thin molecule (EventSoonChip, used by EventItem and
    EventPanel, stays a small wrapper over Chip + isSoon()).

4. Flatten story titles

  • Every *.stories.tsx: set title to the bare tier ('Atoms' / 'Molecules' /
    'Organisms'); component name stays in Default.storyName. Removes all
    / Subcategory second levels.

5. Standardize props (rename + update all call sites)

Component Change
ListItem link → href
ListHeader, SearchBar returnLink → backHref
Lightbox open → isOpen, close → onClose
RegistrationModal (now private) isOnline → online (match the Event schema field)
EventTimingDetails convertTimeZone → showTimeZone (match EventTime)
EventTime document that delay only applies when showTimeZone is set

Naming rule to document: state/behavior booleans use isX; props that pass through a
zod/schema field keep the field name (online); handlers use onX.

6. Minor visual-consistency pass

  • Align the two modals (ShareModal, RegistrationModal) on shared header/body/footer
    spacing & typography.
  • Verify chips (EventSoonChip, online/offline chips in EventItem/EventPanel) use a
    consistent color/emphasis token set.
  • Reconcile sticky-header spacing/sizing between ListHeader and SearchBar.
  • Keep changes cosmetic and small; capture before/after screenshots.

7. Documentation

  • DESIGN_SYSTEM.md — rewrite the export section (explicit named exports only; the
    "what NOT to export" list; the named exception list; "atoms stay primitive / domain
    logic → src/lib/"; the inline-single-use rule). Add src/lib/ to the file layout.
  • STORYBOOK.md — replace the subcategory map with the single-level title convention.
  • .claude/rules/components.md — update the structure/export bullets to match.

Acceptance criteria

  • No export * remains in component or tier barrels; each exports only its primary
    component(s) + Props type, except the four documented exceptions.
  • isSoon() + tz-format helper live in src/lib/events.ts; no component barrel
    re-exports a helper, constant, or variant map.
  • ShareModal/ShareContent, RegistrationModal/RegistrationFields, the
    EventDetail primitive, and TimezoneChip are private to their parent and no
    longer appear as separate Ladle sidebar entries.
  • Chip contains no time/date/domain logic; EventSoonChip remains a thin molecule.
  • Ladle sidebar shows exactly three top-level groups (Atoms / Molecules / Organisms)
    with no second level.
  • Props renamed per the table above and all call sites updated
    (src/pages/*, src/App.tsx, component cross-imports).
  • DESIGN_SYSTEM.md, STORYBOOK.md, and .claude/rules/components.md reflect the
    new export + story + naming conventions.
  • No visual or behavioral regression (verified by Playwright spot-check of the event
    panel, share/registration modals, list/search navigation, theme/locale switch).
  • pnpm typecheck, pnpm lint, pnpm test:run, pnpm ladle:build, and
    pnpm build all pass.

Files affected

Pattern repeats across all 24 component folders; key touch points:

  • src/components/*/index.ts (all barrels) + the three tier index.ts
  • src/components/atoms/Chip/Chip.tsx, atoms/Lightbox/Lightbox.tsx
  • src/components/molecules/EventTime/EventTime.tsx, EventSoon/EventSoon.tsx,
    EventShare/EventShare.tsx, List*/, SearchBar/
  • src/components/organisms/EventRegistration/EventRegistration.tsx,
    EventDetails/EventDetails.tsx, EventPanel/EventPanel.tsx,
    EventsList/EventsList.tsx
  • New src/lib/events.ts
  • Docs: DESIGN_SYSTEM.md, STORYBOOK.md, .claude/rules/components.md

Out of scope (future work)

  • Building WeMeditate-style atoms we lack (Badge, Tooltip wrapper, Breadcrumbs, …) —
    deferred given the NextUI-direct philosophy.
  • Optional deeper splits (Fallbacks/ → LoadingFallback/ + ErrorFallback/,
    MapSearch into its own folder) — follow-ups, not blockers.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Hold Until

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions