Skip to content

Commit efea5c1

Browse files
committed
docs: move storybook details from docs -> contributing guide
1 parent 5c6163c commit efea5c1

5 files changed

Lines changed: 118 additions & 110 deletions

File tree

CONTRIBUTING.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ This focus helps guide our project decisions as a community and what we choose t
6060
- [Lighthouse performance tests](#lighthouse-performance-tests)
6161
- [End to end tests](#end-to-end-tests)
6262
- [Test fixtures (mocking external APIs)](#test-fixtures-mocking-external-apis)
63+
- [Storybook](#storybook)
64+
- [Component categories](#component-categories)
65+
- [Coverage guidelines](#coverage-guidelines)
66+
- [Project conventions](#project-conventions)
67+
- [Configuration](#configuration)
68+
- [Global app settings](#global-app-settings)
69+
- [Known limitations](#known-limitations)
6370
- [Submitting changes](#submitting-changes)
6471
- [Before submitting](#before-submitting)
6572
- [Pull request process](#pull-request-process)
@@ -885,6 +892,117 @@ The mock connector supports test endpoints for state manipulation:
885892
- `/__test__/user-packages` - Set user's packages
886893
- `/__test__/package` - Set package collaborators
887894

895+
## Storybook
896+
897+
Storybook is a development environment for UI components that helps catch UI changes and provides integrations for various testing types. For testing, Storybook offers:
898+
899+
- **Accessibility tests** - Built-in a11y checks
900+
- **Visual tests** - Compare JPG screenshots
901+
- **Vitest tests** - Use stories directly in the unit tests
902+
903+
### Component categories
904+
905+
The plan is to organize components into 3 categories.
906+
907+
#### UI Library Components
908+
909+
Generic and reusable components used throughout the application.
910+
911+
- Examples: Button, Input, Modal, Card
912+
- **Testing focus:** Props, variants, accessibility
913+
- **Coverage:** All variants and states
914+
915+
#### Composite Components
916+
917+
Single-use components that encapsulate one feature.
918+
919+
- Examples: UserProfile, WeeklyDownloadStats
920+
- **Testing focus:** Integration patterns, user interactions
921+
- **Coverage:** Common usage scenarios
922+
923+
#### Page Components
924+
925+
**Full-page layouts** should match what the users see.
926+
927+
- Examples: HomePage, Dashboard, CheckoutPage
928+
- **Testing focus:** Layout, responsive behavior, integration testing
929+
- **Coverage:** Critical user flows and breakpoints
930+
931+
### Coverage guidelines
932+
933+
#### Which Components Need Stories?
934+
935+
TBD
936+
937+
### Project conventions
938+
939+
#### Place `.stories.ts` files next to the component
940+
941+
```sh
942+
components/
943+
├── Button.vue
944+
└── Button.stories.ts
945+
```
946+
947+
#### Story Template
948+
949+
```ts
950+
// *.stories.ts
951+
import type { Meta, StoryObj } from '@storybook-vue/nuxt'
952+
import Component from './Button.vue'
953+
954+
const meta = {
955+
component: Component,
956+
// component scope configuration goes here
957+
} satisfies Meta<typeof Component>
958+
959+
export default meta
960+
type Story = StoryObj<typeof meta>
961+
962+
export const Default: Story = {
963+
// story scope configuration goes here
964+
}
965+
```
966+
967+
#### JSDocs Annotation
968+
969+
The component should include descriptive comments.
970+
971+
```ts
972+
// Button.vue
973+
<script setup lang="ts">
974+
const props = withDefaults(
975+
defineProps<{
976+
/** Whether the button is disabled */
977+
disabled?: boolean
978+
/**
979+
* HTML button type attribute
980+
* @default "button"
981+
type?: 'button' | 'submit'
982+
// ...
983+
}>)
984+
</script>
985+
```
986+
987+
### Configuration
988+
989+
Stories can be configured at three levels:
990+
991+
- **Global scope** (`.storybook/preview.ts`) - Applies to all stories
992+
- **Component scope** - Applies to all stories for a specific component
993+
- **Story scope** - Applies to individual stories only
994+
995+
### Global app settings
996+
997+
Global application settings are added to the Storybook toolbar for easy testing and viewing. Configure these in `.storybook/preview.ts` under the `globalTypes` and `decorators` properties.
998+
999+
### Known limitations
1000+
1001+
- Changing `i18n` in the toolbar doesn't update the language. A manual story reload is required.
1002+
- `autodocs` currently is non-functional due bugs, its usage is discouraged at this time.
1003+
- `pnpm build-storybook` currently fails, use `pnpm storybook` to view the stories for the time being.
1004+
- `pnpm storybook` may log warnings or non-breaking errors for Nuxt modules due to the lack of mocks. If the UI renders correctly, these can be safely ignored.
1005+
8881006
## Submitting changes
8891007
8901008
### Before submitting

docs/content/2.guide/4.storybook.md

Lines changed: 0 additions & 110 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)