Component Catalog Pipeline
How co-located UI stories and optional component docs become the styleguide catalog.
Story files are the catalog input
Component catalog entries start in packages/. Each story file is co-located with the component it documents and exports:
a default
StoryMetaobject with title, category, description, usage, and optional order;one or more named
Story<P>exports with a pure synchronousrenderfunction;optional
controlsmetadata and optional explicitsourcestrings for code panels.
The catalog renders stories during static build, so story rendering must not depend on browser globals, timers, network calls, or async data.
Codegen replaces runtime globbing
The catalog does not discover stories with import.meta.glob at runtime. zfb does not inline that call into shared client islands, so zudo-sg uses code generation instead.
scripts/ scans packages/ (any nesting depth) and regenerates explicit import registries:
src/for the root styleguide catalog.styleguide/ data/ sg- registry. ts packages/for story contract and drift tests.ui/ src/ stories/ _ _ tests_ _ / story- modules. ts
After adding, renaming, or deleting a story file, run:
pnpm gen:sg-registryCI and local quality gates run:
pnpm check:sg-registryThat check fails when the generated registries no longer match the story files on disk.
Generated blocks
Do not hand-edit code between GENERATED:SG_REGISTRY_BEGIN and GENERATED:SG_REGISTRY_END. Regenerate it from the story files.
Optional component MDX
Quick reference content lives in story metadata. When a component needs more guidance, add an optional MDX file next to the component and story:
packages/ui/src/cards/card/card.tsx
packages/ui/src/cards/card/card.stories.tsx
packages/ui/src/cards/card/card.mdxThe root host compiles those MDX files through a componentDocs collection rooted at packages/. Component detail pages look up the matching MDX entry from the same component path the story registry uses, so there is no separate registration step.
Authoring checklist
When adding a component, ship the component, story, tests, exports, and any optional MDX docs together. Then run the focused checks from Quality Gates: typecheck, unit tests, token lint, and story registry drift detection.