-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: moved storybook config to config library
- Loading branch information
Showing
37 changed files
with
236 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './decorators' | ||
export { createViewPorts } from './config/viewports' | ||
export * from './lib' |
11 changes: 11 additions & 0 deletions
11
libs/client-shared/src/storybook/lib/create-storybook-variant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Decorator } from '@storybook/react' | ||
|
||
export const createStorybookVariant = <T>(defaultArgs: T) => { | ||
return (additionalArgs: Partial<T> = {}, decorators: Decorator[] = []) => ({ | ||
args: { | ||
...defaultArgs, | ||
...additionalArgs | ||
}, | ||
decorators | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { createStorybookVariant } from 'src/storybook/lib/create-storybook-variant' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export * from './lib/client' | ||
export * from './lib/server' | ||
export * from './consts/client' | ||
export * from './consts/server' | ||
|
||
export { createStorybookConfig } from './storybook/create-storybook-config' | ||
export { createPreviewDefaults } from './storybook/create-preview-defaults' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Decorator, Preview } from '@storybook/react' | ||
import { createViewPorts } from './plugins/create-viewports' | ||
|
||
interface PreviewDefaultsPayload { | ||
decorators: Decorator[] | ||
} | ||
|
||
type CreatePreviewDefaults = (args: PreviewDefaultsPayload) => Preview | ||
|
||
export const createPreviewDefaults: CreatePreviewDefaults = ({ | ||
decorators | ||
}) => ({ | ||
parameters: { | ||
viewport: { | ||
viewports: createViewPorts() | ||
}, | ||
actions: { argTypesRegex: '^on[A-Z].*' }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/ | ||
} | ||
}, | ||
backgrounds: { | ||
values: [] | ||
}, | ||
storySort: (a, b) => | ||
a.id === b.id ? 0 : a.id.localeCompare(b.id, undefined, { numeric: true }) | ||
}, | ||
decorators | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { StorybookConfig } from '@storybook/react-vite' | ||
|
||
interface StorybookConfigPayload { | ||
viteConfigPath: string | ||
viteFinal: (config: StorybookConfig) => StorybookConfig | ||
} | ||
|
||
type CreateStorybookConfig = (args: StorybookConfigPayload) => StorybookConfig | ||
|
||
export const createStorybookConfig: CreateStorybookConfig = ({ | ||
viteConfigPath, | ||
viteFinal | ||
}) => ({ | ||
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'], | ||
addons: ['@storybook/addon-essentials', '@storybook/addon-interactions'], | ||
framework: { | ||
name: '@storybook/react-vite', | ||
options: { | ||
builder: { | ||
viteConfigPath | ||
} | ||
} | ||
}, | ||
viteFinal | ||
}) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
"../../.eslintrc.js" | ||
], | ||
"ignorePatterns": [ | ||
"!**/*" | ||
"!**/*", | ||
".storybook" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
import { createStorybookConfig } from 'cg-config/src' | ||
import type { StorybookConfig } from '@storybook/react-vite' | ||
import { mergeConfig } from 'vite' | ||
import viteTsConfigPaths from 'vite-tsconfig-paths' | ||
|
||
const config: StorybookConfig = { | ||
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'], | ||
addons: ['@storybook/addon-essentials', '@storybook/addon-interactions'], | ||
framework: { | ||
name: '@storybook/react-vite', | ||
options: { | ||
builder: { | ||
viteConfigPath: 'libs/ui/vite.config.ts' | ||
} | ||
} | ||
}, | ||
viteFinal: (config) => { | ||
const config: StorybookConfig = createStorybookConfig({ | ||
viteConfigPath: 'libs/ui/vite.config.ts', | ||
viteFinal: (config: StorybookConfig): StorybookConfig => { | ||
return mergeConfig(config, { | ||
define: { | ||
'process.env': process.env | ||
} | ||
}, | ||
plugins: [ | ||
viteTsConfigPaths() | ||
] | ||
}) | ||
} | ||
} | ||
}) | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,9 @@ | ||
import { | ||
createViewPorts, | ||
ThemeDecorator, | ||
StylesDecorator | ||
} from '$/client-shared' | ||
import { Preview, Decorator } from '@storybook/react' | ||
import { StylesDecorator, ThemeDecorator } from '$/client-shared' | ||
import { Preview } from '@storybook/react' | ||
import { createPreviewDefaults } from '$/config' | ||
|
||
const decorators: Decorator[] = [StylesDecorator, ThemeDecorator] | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
viewport: { | ||
viewports: createViewPorts() | ||
}, | ||
actions: { argTypesRegex: '^on[A-Z].*' }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/ | ||
} | ||
}, | ||
backgrounds: { | ||
values: [] | ||
} | ||
}, | ||
decorators | ||
} | ||
const preview: Preview = createPreviewDefaults({ | ||
decorators: [StylesDecorator, ThemeDecorator] | ||
}) | ||
|
||
export default preview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.