Skip to content

Commit 7a1b6ec

Browse files
docs(storybooks): implement ADR-013 documentation guidelines (#635)
Co-authored-by: Sebastian Schütze <sebastian.schuetze@razorspoint.com>
1 parent d8393d0 commit 7a1b6ec

34 files changed

+412
-8
lines changed

.github/instructions/stories.instructions.md

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,42 @@ These rules apply to all Storybook stories (`*.stories.tsx`) and ensure they are
1414

1515
## Implementation Rules
1616

17-
### Documentation Location
17+
### Documentation Location (ADR-013)
18+
19+
This repository follows **ADR-013: Storybook Documentation Location** (see `docs/adrs/013-adr-storybook-documentation-location.md`).
20+
21+
**Autodocs-First Approach:**
22+
23+
- **Primary documentation** lives in story files via Autodocs. Stories must include the `autodocs` tag in their `tags` array (for example, `tags: ['autodocs']`).
24+
- All stories **must** include the `autodocs` tag in their `tags` array to enable automatic documentation generation.
25+
- Add a short component description via `parameters.docs.description.component` when it helps clarify the component's purpose or key behaviors.
26+
- Keep descriptions concise (1-3 sentences). Example:
27+
```tsx
28+
const meta = {
29+
title: 'Atoms/Button',
30+
component: Button,
31+
tags: ['autodocs'],
32+
parameters: {
33+
docs: {
34+
description: {
35+
component:
36+
'Primary interactive element for user actions. Supports multiple variants and sizes for different contexts.',
37+
},
38+
},
39+
},
40+
} satisfies Meta<typeof Button>
41+
```
42+
43+
**When to Use MDX:**
1844

19-
- **Primary documentation** lives in story files via Autodocs (`tags: ['autodocs']`) and short component descriptions in story metadata.
2045
- **Use Storybook MDX docs** only for cross-cutting guidance, complex workflows, or narrative explanations that do not fit inside Autodocs.
21-
- **Use repository docs** (like ADRs) only for system-wide decisions or infra-level guidance; do not duplicate component documentation there.
46+
- Examples: design system patterns, compound component usage guides, accessibility best practices across multiple components.
47+
- Do **NOT** create MDX files for individual component documentation—use story metadata instead.
48+
49+
**Repository Docs:**
50+
51+
- **Use repository docs** (like ADRs in `docs/adrs/`) only for system-wide decisions or infra-level guidance.
52+
- Do **NOT** duplicate component documentation in repository markdown files.
2253

2354
### 0. Images / Assets (Required)
2455

@@ -68,3 +99,19 @@ These rules apply to all Storybook stories (`*.stories.tsx`) and ensure they are
6899
- Stories are run as tests via `pnpm tests`.
69100
- Any story that crashes because of missing providers (Router, QueryClient) is considered a **failed test**.
70101
- Fix failures by mocking the missing dependency in the story, NOT by adding the provider to the global test setup.
102+
103+
## Contributor Checklist (PR Reviews)
104+
105+
When creating or updating stories, ensure:
106+
107+
- [ ] Story includes `autodocs` tag in the tags array for automatic documentation
108+
- [ ] Story metadata includes a concise description via `parameters.docs.description.component` (1-3 sentences) when it clarifies component purpose
109+
- [ ] Story title follows atomic structure: `Atoms/`, `Molecules/`, `Organisms/`, `Templates/`
110+
- [ ] Stories are isolated—no real API calls, navigation, or external dependencies
111+
- [ ] Images/assets are committed to `src/stories/assets/` (no hotlinked URLs except `placehold.co` for ephemeral placeholders)
112+
- [ ] Interactive behaviors are covered by `play()` functions with assertions
113+
- [ ] Mock decorators are used for routing, auth, and fetch when needed
114+
- [ ] Component business logic and visuals remain unchanged (stories only document existing behavior)
115+
- [ ] Tests pass: `pnpm tests` (stories run as Vitest tests)
116+
117+
**Reference**: See [ADR-013](../../docs/adrs/013-adr-storybook-documentation-location.md) for full documentation location guidelines.

.storybook/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createRequire } from 'node:module'
33
import tsconfigPaths from 'vite-tsconfig-paths'
44

55
const config: StorybookConfig = {
6-
stories: ['../src/stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
6+
stories: ['../src/stories/**/*.stories.@(js|jsx|mjs|ts|tsx)', '../src/stories/**/*.mdx'],
77
addons: [
88
'@chromatic-com/storybook',
99
'@storybook/addon-vitest',

eslint.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const eslintConfig = [
4242
},
4343
},
4444
{
45-
files: ['src/stories/**/*.{ts,tsx,mdx}'],
45+
files: ['src/stories/**/*.{ts,tsx}'],
4646
// Enforce correct Storybook framework imports to avoid mixing Next.js/React renderers
4747
rules: {
4848
'no-restricted-imports': [
@@ -119,6 +119,7 @@ const eslintConfig = [
119119
'src/payload-types.ts',
120120
'src/app/(payload)/**',
121121
'next-env.d.ts',
122+
'src/stories/**/*.mdx',
122123
],
123124
},
124125
...storybook.configs['flat/recommended'],

public/stories/flower.mp4

1.08 MB
Binary file not shown.

src/stories/atoms/Button.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ const meta = {
66
title: 'Atoms/Button',
77
component: Button,
88
tags: ['autodocs'],
9+
parameters: {
10+
docs: {
11+
description: {
12+
component:
13+
'Primary interactive element for user actions. Supports multiple variants (primary, secondary, destructive, etc.) and sizes for different contexts.',
14+
},
15+
},
16+
},
917
argTypes: {
1018
variant: {
1119
control: 'select',

src/stories/atoms/Dialog.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ const meta = {
1616
title: 'Atoms/Dialog',
1717
component: Dialog,
1818
tags: ['autodocs'],
19+
parameters: {
20+
docs: {
21+
description: {
22+
component:
23+
'Modal dialog compound component for critical user interactions. Built with a Dialog root component and DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, and DialogClose sub-components for composable layouts.',
24+
},
25+
},
26+
},
1927
} satisfies Meta<typeof Dialog>
2028

2129
export default meta

src/stories/atoms/Heading.stories.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ const meta = {
88
tags: ['autodocs'],
99
parameters: {
1010
layout: 'padded',
11+
docs: {
12+
description: {
13+
component:
14+
'Semantic heading component with controlled typography hierarchy (h1-h6). Requires explicit alignment prop to ensure consistent text positioning.',
15+
},
16+
},
1117
},
1218
args: {
1319
as: 'h2',

src/stories/atoms/Input.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ const meta = {
77
title: 'Atoms/Input',
88
component: Input,
99
tags: ['autodocs'],
10+
parameters: {
11+
docs: {
12+
description: {
13+
component:
14+
'Text input field for user data entry. Supports various types (text, email, password) and validation states.',
15+
},
16+
},
17+
},
1018
argTypes: {
1119
type: {
1220
control: 'select',

src/stories/atoms/Slider.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Slider } from '@/components/atoms/slider'
66
const meta: Meta<typeof Slider> = {
77
title: 'Atoms/Slider',
88
component: Slider,
9+
tags: ['autodocs'],
910
}
1011

1112
export default meta

src/stories/atoms/VerificationBadge.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { VerificationBadge } from '@/components/atoms/verification-badge'
55
const meta = {
66
title: 'Atoms/VerificationBadge',
77
component: VerificationBadge,
8+
tags: ['autodocs'],
89
} satisfies Meta<typeof VerificationBadge>
910

1011
export default meta

0 commit comments

Comments
 (0)