feat: add Storybook with component stories

Installs @storybook/nextjs-vite. Stories co-located with components,
grouped by layer (Shared/Entities/Widgets). Multi-variant cases use
render functions instead of one story per variant/size.
This commit is contained in:
Ilia Mashkov
2026-04-19 09:19:17 +03:00
parent a47341ffcb
commit de03d21429
21 changed files with 2052 additions and 16 deletions
+35
View File
@@ -0,0 +1,35 @@
import path from 'path'
import { fileURLToPath } from 'url'
import type { StorybookConfig } from '@storybook/nextjs-vite'
const dirname = path.dirname(fileURLToPath(import.meta.url))
const config: StorybookConfig = {
stories: [
'../src/**/*.mdx',
'../src/**/*.stories.@(js|jsx|mjs|ts|tsx)',
],
addons: [
'@chromatic-com/storybook',
'@storybook/addon-vitest',
'@storybook/addon-a11y',
'@storybook/addon-docs',
],
framework: '@storybook/nextjs-vite',
staticDirs: ['../public'],
viteFinal: async (config) => {
config.resolve ??= {}
config.resolve.alias = {
...(config.resolve.alias as Record<string, string>),
'$shared': path.resolve(dirname, '../src/shared'),
'$entities': path.resolve(dirname, '../src/entities'),
'$features': path.resolve(dirname, '../src/features'),
'$widgets': path.resolve(dirname, '../src/widgets'),
'$app': path.resolve(dirname, '../src/app'),
'$routes': path.resolve(dirname, '../src/routes'),
}
return config
},
}
export default config
+21
View File
@@ -0,0 +1,21 @@
import type { Preview } from '@storybook/nextjs-vite'
import '../app/globals.css'
const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
a11y: {
// 'todo' - show a11y violations in the test UI only
// 'error' - fail CI on a11y violations
// 'off' - skip a11y checks entirely
test: 'todo',
},
},
}
export default preview