File structure
July 5, 2024 ยท View on GitHub
Status
| Stage | Status |
|---|---|
| Approved | โ |
| Adopted | ๐ง |
Context
Components might be more grokable if they were structured consistently. This ADR proposes conventions
Decision
TL;DR:
primer-react/
โโ src/
โ โโ Breadcrumbs/
โ โ โโ index.ts // Just re-exporting?
โ โ โโ Breadcrumbs.tsx // Primary component
โ โ โโ BreadcrumbsItem.tsx // Subcomponent (include parent component name to increase findability in most IDEs)
โ โ โโ Breadcrumbs.mdx // Documentation. Always .mdx, not .md
โ โ โโ Breadcrumbs.stories.tsx
โ โ โโ Breadcrumbs.test.tsx // Unit tests
โ โ โโ Breadcrumbs.types.test.tsx // Type tests
โ โ โโ Breadcrumbs.yml // Component metadata (Possible future)
โ โ โโ __snapshots__/
โ โ
Rules
- Every component should have its own PascalCased directory directly under
src/ - Subcomponents should be properties of the exported parent component (e.g.,
Breadcrumbs.Item) - Replacements of existing components should use an incrementing number (e.g.,
Breadcrumbs2rather thanNewBreadcrumbs)
Implementation
- Migrate components into this structure (as part of Storybook refactor work)
- Set up tests for the component structure
- Mark this ADR as adopted