Skip to content

Commit 84863ed

Browse files
jfuchscolebemis
authored andcommitted
Propose a new file structure (ADR) (#1678)
* Proposes a new file structure (ADR) * Update contributor-docs/adrs/adr-XXX-file-structure.md Co-authored-by: Cole Bemis <colebemis@github.com> * More questions about the implementation process * Doc updates; removal of open questions * BreadCrumbs -> Breadcrumbs * Remove note about separately exported subcomponents * Update contributor-docs/adrs/adr-XXX-file-structure.md Co-authored-by: Cole Bemis <colebemis@github.com> Co-authored-by: Cole Bemis <colebemis@github.com>
1 parent 35ac2d8 commit 84863ed

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# ADR XXX: File structure
2+
3+
## Status
4+
5+
Proposed
6+
7+
## Context
8+
9+
Components might be more grokable if they were structured consistently. This ADR proposes conventions
10+
11+
## Decision
12+
13+
TL;DR:
14+
15+
```
16+
primer-react/
17+
├─ src/
18+
│ ├─ Breadcrumbs/
19+
│ │ ├─ index.ts // Just re-exporting?
20+
│ │ ├─ Breadcrumbs.tsx // Primary component
21+
│ │ ├─ BreadcrumbsItem.tsx // Subcomponent (include parent component name to increase findability in most IDEs)
22+
│ │ ├─ Breadcrumbs.mdx // Documentation. Always .mdx, not .md
23+
│ │ ├─ Breadcrumbs.stories.tsx
24+
│ │ ├─ Breadcrumbs.test.tsx // Unit tests
25+
│ │ ├─ Breadcrumbs.types.test.tsx // Type tests
26+
│ │ ├─ Breadcrumbs.yml // Component metadata (Possible future)
27+
│ │ └─ __snapshots__/
28+
┆ ┆
29+
```
30+
31+
### Rules
32+
33+
- Every component should have its own PascalCased directory directly under `src/`
34+
- Subcomponents should be properties of the exported parent component (e.g., `Breadcrumbs.Item`)
35+
- Replacements of existing components should use an incrementing number (e.g., `Breadcrumbs2` rather than `NewBreadcrumbs`)
36+
37+
## Implementation
38+
39+
- [ ] Migrate components into this structure
40+
- [ ] Set up tests for the component structure
41+
- [ ] Mark this ADR as adopted

0 commit comments

Comments
 (0)