Skip to content

Instantly share code, notes, and snippets.

@BishopKO
Created July 20, 2020 05:06
Show Gist options
  • Save BishopKO/5be36d57ca40682d0145554bcf5e8d84 to your computer and use it in GitHub Desktop.
Save BishopKO/5be36d57ca40682d0145554bcf5e8d84 to your computer and use it in GitHub Desktop.
### 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