Skip to content

Commit 4478f7e

Browse files
committed
README
1 parent f24ce4d commit 4478f7e

1 file changed

Lines changed: 135 additions & 0 deletions

File tree

.storybook/README.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Why are we using Storybook?
2+
3+
Storybook is a development environment for UI components that helps catch changes in UI while also having integrations for different kinds of tests. For testing, Storybook provides:
4+
5+
- **Accessibility tests** - Built-in a11y checks (link to example)
6+
- **Visual tests** - Compare JPG screenshots (link to example)
7+
- **Snapshot tests** - Compare HTML output (link to example)
8+
- **Vitest tests** - Use stories directly in your unit tests (link to example)
9+
10+
## Component Categories
11+
12+
We organize components into 3 categories.
13+
14+
### UI Library Components
15+
16+
**Generic, reusable components** used throughout your application.
17+
18+
- Examples: Button, Input, Modal, Card
19+
- **Testing focus:** Props, variants, accessibility
20+
- **Coverage:** All variants and states
21+
22+
### Composite Components
23+
24+
**Domain-specific components** built from UI library components.
25+
26+
- Examples: UserProfile, ProductCard, SearchForm
27+
- **Testing focus:** Integration patterns, user interactions
28+
- **Coverage:** Common usage scenarios
29+
30+
### Page Components
31+
32+
**Full-page layouts** shown to end users.
33+
34+
- Examples: HomePage, Dashboard, CheckoutPage
35+
- **Testing focus:** Layout, responsive behavior, integration testing
36+
- **Coverage:** Critical user flows and breakpoints
37+
38+
## Coverage Guidelines
39+
40+
### Which Components Need Stories?
41+
42+
TBD
43+
44+
### Convention
45+
46+
- An edge case per story
47+
- Do not use `autodocs`
48+
49+
# How to Use
50+
51+
## Writing Stories
52+
53+
1. **Create your first story** - Place a `.stories.ts` file next to your component:
54+
55+
```
56+
components/
57+
├── Button.vue
58+
└── Button.stories.ts
59+
```
60+
61+
2. **Add the story code** - Each story file follows this pattern:
62+
63+
```ts
64+
// Button.stories.ts
65+
import type { Meta, StoryObj } from '@nuxtjs/storybook'
66+
import Component from './Button.vue'
67+
68+
const meta = {
69+
component: Component,
70+
// component configuration goes here
71+
} satisfies Meta<typeof Component>
72+
73+
export default meta
74+
type Story = StoryObj<typeof meta>
75+
76+
export const Default: Story = {
77+
// story configuration goes here
78+
}
79+
```
80+
81+
3. **Run Storybook locally:**
82+
83+
```sh
84+
pnpm storybook
85+
```
86+
87+
4. **Find your story** - Storybook URLs mirror your project structure.
88+
89+
For a component at `app/components/Button/Button.stories.ts`, the story will be available at `http://localhost:6006/?path=/story/components-button--default`
90+
91+
## Configuration
92+
93+
### Global Configuration (`.storybook/preview.ts`)
94+
95+
Affects all stories across the project:
96+
97+
```ts
98+
export default {
99+
globals: {
100+
locale: 'en-US',
101+
},
102+
}
103+
```
104+
105+
### Component Configuration (meta)
106+
107+
Overrides settings for a specific component:
108+
109+
```ts
110+
const meta = {
111+
component: Button,
112+
parameters: {
113+
layout: 'centered',
114+
},
115+
globals: {
116+
locale: 'ja-JP',
117+
},
118+
}
119+
```
120+
121+
### Story Configuration
122+
123+
Overrides settings for individual stories:
124+
125+
```ts
126+
export const SpecialCase: Story = {
127+
globals: {
128+
locale: 'fr-FR',
129+
},
130+
}
131+
```
132+
133+
## Global App Settings
134+
135+
Global application settings are added to the Storybook toolbar for easy testing and viewing. Configure these in `.storybook/preview.ts` using the `globals` property with toolbar definitions.

0 commit comments

Comments
 (0)