Created
July 20, 2020 05:06
-
-
Save BishopKO/5be36d57ca40682d0145554bcf5e8d84 to your computer and use it in GitHub Desktop.
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
### config.js ### | |
import { configure, addDecorator } from '@storybook/react'; | |
import themeDecorator from './themeDecorator'; | |
addDecorator(themeDecorator); | |
const loaderFn = () => { | |
const req = require.context('../src/components', true, /\.stories\.js$/); | |
req.keys().forEach(fname => req(fname)); | |
}; | |
configure(loaderFn, module); | |
### themeDecorator.js ### | |
import React from 'react'; | |
import mainTheme from 'theme/mainTheme'; | |
import { ThemeProvider } from 'styled-components'; | |
const ThemeDecorator = storyFn => ( | |
<ThemeProvider theme={mainTheme}>{storyFn()}</ThemeProvider> | |
); | |
export default ThemeDecorator; | |
### main.js ### | |
module.exports = { | |
stories: ['../src/**/*.stories.js'], | |
addons: [ | |
'@storybook/preset-create-react-app', | |
'@storybook/addon-actions', | |
'@storybook/addon-links', | |
], | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment