Each demo/prototype must be completely independent and contained within its own folder inside src/demos/.
src/
demos/
[demo-name]/
[DemoName].tsx # Main demo component
[DemoName].css # Demo-specific styles
components/ # Internal demo components (optional)
utils/ # Demo-specific utilities (optional)
types/ # Demo-specific TypeScript types (optional)
hooks/ # Demo-specific custom hooks (optional)
-
Total Independence: Each demo must be completely independent and not depend on other demos.
-
No Cross-Dependencies:
- Demos MUST NOT import components, utilities, or types from other demos.
- Demos MUST NOT share state with other demos.
-
Shared Components:
- Only components in
src/components/can be shared between demos. - These components must be generic and reusable.
- Only components in
-
Adding/Removing Prototypes:
- To add a new demo: create a new folder in
src/demos/and add the button inDashboard.tsx. - To remove a demo: delete the entire folder and remove the button from the dashboard.
- There should be no side effects when adding or removing demos.
- To add a new demo: create a new folder in
-
File Structure:
- Each demo must export its main component as a named export:
export function DemoName() { ... } - Styles must be in a separate CSS file with the same name.
- Each demo must export its main component as a named export:
-
Dashboard Integration:
- Add the button in
src/components/Dashboard.tsxinside.demo-grid. - Add the case in
src/App.tsxinside the active demos switch. - The
demoIdmust match the folder name.
- Add the button in
To add a new demo called "ThreeJS":
- Create folder:
src/demos/threejs/ - Create component:
src/demos/threejs/ThreeJSDemo.tsx - Create styles:
src/demos/threejs/ThreeJSDemo.css - Add button in
Dashboard.tsx:<button className="demo-card threejs-card" onClick={() => onDemoSelect('threejs')} > {/* button content */} </button>
- Add case in
App.tsx:{activeDemo === 'threejs' && <ThreeJSDemo />}
- Demo folders:
kebab-case(e.g.,mapbox,threejs,webgl) - Components:
PascalCase(e.g.,MapboxDemo,ThreeJSDemo) - CSS files: same name as component (e.g.,
MapboxDemo.css)
- Keeping each demo as a self-contained module facilitates maintenance and scalability.
- This architecture allows working on multiple prototypes without interference.
- Prototypes can be removed without affecting the rest of the system.