Skip to content

Commit

Permalink
Propose a new file structure (ADR) (#1678)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
jfuchs and colebemis authored Dec 16, 2021
1 parent fa6c311 commit b05472e
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions contributor-docs/adrs/adr-XXX-file-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ADR XXX: File structure

## Status

Proposed

## 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., `Breadcrumbs2` rather than `NewBreadcrumbs`)

## Implementation

- [ ] Migrate components into this structure
- [ ] Set up tests for the component structure
- [ ] Mark this ADR as adopted

0 comments on commit b05472e

Please sign in to comment.