-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update to storybook 7, webpack 5, node 18 (#457)
* feat: update to storybook 7, webpack 5, node 18
- Loading branch information
1 parent
32a68f2
commit 95955ab
Showing
103 changed files
with
24,837 additions
and
24,399 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"sourceType": "unambiguous", | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"chrome": 100 | ||
} | ||
} | ||
], | ||
"@babel/preset-typescript", | ||
"@babel/preset-react" | ||
], | ||
"plugins": [] | ||
} |
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
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 +1,2 @@ | ||
registry=https://registry.npmjs.org | ||
registry=https://registry.npmjs.org | ||
legacy-peer-deps=true |
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 +1 @@ | ||
14 | ||
18 |
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,28 @@ | ||
import React from 'react'; | ||
|
||
import {addons, types} from '@storybook/addons'; | ||
import {useGlobals} from '@storybook/api'; | ||
import type {API} from '@storybook/api'; | ||
|
||
import {themes} from '../../theme'; | ||
|
||
const ADDON_ID = 'yc-theme-addon'; | ||
const TOOL_ID = `${ADDON_ID}tool`; | ||
|
||
addons.register(ADDON_ID, (api) => { | ||
addons.add(TOOL_ID, { | ||
type: types.TOOL, | ||
title: 'Theme', | ||
render: () => { | ||
return <Tool api={api} />; | ||
}, | ||
}); | ||
}); | ||
|
||
function Tool({api}: {api: API}) { | ||
const [{theme}] = useGlobals(); | ||
React.useEffect(() => { | ||
api.setOptions({theme: themes[theme]}); | ||
}, [theme]); | ||
return null; | ||
} |
4 changes: 2 additions & 2 deletions
4
.storybook/addons/addon-yaml/AddonYaml.css → .storybook/addons/yaml-addon/AddonYaml.css
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,8 +1,8 @@ | ||
.addon-yaml { | ||
.yaml-addon { | ||
padding: 11px; | ||
} | ||
|
||
.addon-yaml pre { | ||
.yaml-addon pre { | ||
margin: 10px 0 0; | ||
padding: 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
$root: '.docs-decorator'; | ||
|
||
#{$root}#{$root}#{$root}#{$root}#{$root} { | ||
.sbdocs-wrapper { | ||
padding: 20px; | ||
|
||
h1 { | ||
margin-bottom: 32px; | ||
} | ||
} | ||
|
||
.sbdocs-content { | ||
max-width: 1680px; | ||
} | ||
|
||
.innerZoomElementWrapper { | ||
overflow: hidden; | ||
} | ||
} |
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,29 @@ | ||
import {DocsContainer} from '@storybook/addon-docs'; | ||
import type {DocsContainerProps} from '@storybook/addon-docs'; | ||
import block from 'bem-cn-lite'; | ||
import React from 'react'; | ||
|
||
import {themes} from '../../theme'; | ||
import {MobileContext} from '../../../src/context/mobileContext'; | ||
import {ThemeProvider} from '../../../src/context/theme/ThemeProvider'; | ||
|
||
import './DocsDecorator.scss'; | ||
|
||
export interface DocsDecoratorProps extends React.PropsWithChildren<DocsContainerProps> {} | ||
|
||
const b = block('docs-decorator'); | ||
|
||
export function DocsDecorator({children, context}: DocsDecoratorProps) { | ||
// @ts-expect-error | ||
const theme = context.store.globals.globals.theme; | ||
|
||
return ( | ||
<div className={b()}> | ||
<DocsContainer context={context} theme={themes[theme as 'dark' | 'light']}> | ||
<ThemeProvider theme={theme}> | ||
<MobileContext.Provider value={false}>{children}</MobileContext.Provider> | ||
</ThemeProvider> | ||
</DocsContainer> | ||
</div> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,54 +1,45 @@ | ||
const {join, resolve} = require('path'); | ||
const WebpackShellPlugin = require('webpack-shell-plugin'); | ||
import {resolve} from 'path'; | ||
import WebpackShellPluginNext from 'webpack-shell-plugin-next'; | ||
|
||
const customAlias = { | ||
widget: resolve(__dirname, '../widget'), | ||
}; | ||
|
||
const config = { | ||
stories: ['../src/**/*.stories.@(ts|tsx)'], | ||
framework: { | ||
name: '@storybook/react-webpack5', | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: true, | ||
}, | ||
stories: ['./stories/**/*.mdx', '../src/**/*.stories.@(ts|tsx)'], | ||
addons: [ | ||
'@storybook/preset-scss', | ||
{name: '@storybook/addon-essentials', options: {backgrounds: false}}, | ||
'@storybook/addon-knobs', | ||
'./addons/addon-yaml/preset', | ||
], | ||
typescript: { | ||
check: true, | ||
checkOptions: {}, | ||
reactDocgen: 'react-docgen-typescript', | ||
reactDocgenTypescriptOptions: { | ||
setDisplayName: false, | ||
shouldExtractLiteralValuesFromEnum: true, | ||
compilerOptions: { | ||
allowSyntheticDefaultImports: true, | ||
esModuleInterop: true, | ||
{ | ||
name: '@storybook/addon-essentials', | ||
options: { | ||
backgrounds: false, | ||
}, | ||
}, | ||
}, | ||
'@storybook/addon-knobs', | ||
'./addons/yaml-addon/preset', | ||
'./addons/theme-addon/register.tsx', | ||
], | ||
webpackFinal: (storybookBaseConfig: any) => { | ||
storybookBaseConfig.module.rules.push({ | ||
test: /\.md$/, | ||
include: [join(__dirname, '..')], | ||
use: [{loader: 'markdown-loader'}], | ||
}); | ||
|
||
// to turn fileName in context.parameters into path form number in production bundle | ||
storybookBaseConfig.optimization.moduleIds = 'named'; | ||
|
||
storybookBaseConfig.plugins.push( | ||
new WebpackShellPlugin({ | ||
onBuildStart: ['npm run build:widget'], | ||
new WebpackShellPluginNext({ | ||
onBuildStart: { | ||
scripts: ['npm run build:widget'], | ||
blocking: true, | ||
}, | ||
}), | ||
); | ||
|
||
storybookBaseConfig.resolve.alias = { | ||
...(storybookBaseConfig.resolve?.alias || {}), | ||
...customAlias, | ||
}; | ||
|
||
return storybookBaseConfig; | ||
}, | ||
}; | ||
|
||
module.exports = config; | ||
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,6 +1,6 @@ | ||
import {addons} from '@storybook/addons'; | ||
import {CloudTheme} from './theme'; | ||
import {themeLight} from './theme'; | ||
|
||
addons.setConfig({ | ||
theme: CloudTheme, | ||
theme: themeLight, | ||
}); |
Oops, something went wrong.