Skip to content

Commit efbf6d7

Browse files
SgtPookiCopilot
andauthored
test: add storybook to more easily test and show ui changes (#95)
* fix: display tx prefix while showing transaction * chore: fix lint * test: add storybook to more easily test and show ui changes * Update vite.config.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update vite.config.ts * chore: merge main and add story * fix: update stories * test: remove unnecessary textWithCopyToClipboard stories * chore: fix lint --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent fa20ca7 commit efbf6d7

12 files changed

Lines changed: 2555 additions & 851 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ next-env.d.ts
3030
# Environment variables
3131
.env
3232
.env.local
33+
34+
*storybook.log
35+
storybook-static

.storybook/main.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { StorybookConfig } from '@storybook/react-vite'
2+
3+
const config: StorybookConfig = {
4+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
5+
addons: [
6+
'@chromatic-com/storybook',
7+
'@storybook/addon-docs',
8+
'@storybook/addon-onboarding',
9+
'@storybook/addon-a11y',
10+
'@storybook/addon-vitest',
11+
],
12+
framework: {
13+
name: '@storybook/react-vite',
14+
options: {},
15+
},
16+
}
17+
export default config

.storybook/preview.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { Preview } from '@storybook/react-vite'
2+
import '../src/index.css'
3+
4+
const preview: Preview = {
5+
parameters: {
6+
controls: {
7+
matchers: {
8+
color: /(background|color)$/i,
9+
date: /Date$/i,
10+
},
11+
},
12+
13+
a11y: {
14+
// 'todo' - show a11y violations in the test UI only
15+
// 'error' - fail CI on a11y violations
16+
// 'off' - skip a11y checks entirely
17+
test: 'todo',
18+
},
19+
},
20+
}
21+
22+
export default preview

.storybook/vitest.setup.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as a11yAddonAnnotations from '@storybook/addon-a11y/preview'
2+
import { setProjectAnnotations } from '@storybook/react-vite'
3+
import * as projectAnnotations from './preview.ts'
4+
5+
// This is an important step to apply the right configuration when testing your stories.
6+
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
7+
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations])

0 commit comments

Comments
 (0)