Adding Components From an Existing Codebase¶
This guide describes how to migrate components from an existing Django project into Django Showroom.
Per-component migration¶
For each component you want to add:
- Create
design-system/cotton/ds/<component>/component.jsonwith metadata. - Create
stories.jsonwith story definitions and defaults. - Create
stories/controls.jsonwith control field definitions. - Copy or create the Cotton template as
index.html. - Add story templates under
stories/*.html. - Optionally add a React preview as
stories/react.preview.ts.
After adding components¶
Run npm run build to:
- Validate all component contracts.
- Regenerate the React story registry.
- Rebuild JS bundles.
Compatibility strategy¶
Keep initial compatibility with existing contracts to reduce migration risk:
- Preserve existing metadata keys.
- Preserve story slug conventions.
- Preserve React preview export shape.
Evolve contracts only after baseline parity is proven.