2017-02-08 16:53:37 +02:00
|
|
|
const React = require('react');
|
|
|
|
const { configure, addDecorator } = require('@kadira/storybook');
|
2016-12-08 14:08:04 +02:00
|
|
|
|
2017-02-08 16:53:37 +02:00
|
|
|
const req = require.context('../src/components', true, /story.js$/);
|
|
|
|
|
|
|
|
const Styled = require('styled-components');
|
|
|
|
const Base = require('../src/components/base');
|
|
|
|
|
|
|
|
const {
|
|
|
|
injectGlobal
|
|
|
|
} = Styled;
|
|
|
|
|
|
|
|
class StyledDecorator extends React.Component {
|
|
|
|
componentWillMount() {
|
|
|
|
injectGlobal`
|
|
|
|
${Base.global}
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Base>
|
|
|
|
{this.props.children}
|
|
|
|
</Base>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addDecorator((story) => (
|
|
|
|
<StyledDecorator>
|
|
|
|
{story()}
|
|
|
|
</StyledDecorator>
|
|
|
|
));
|
2017-01-11 14:28:45 +02:00
|
|
|
|
2016-12-08 14:08:04 +02:00
|
|
|
function loadStories() {
|
2017-01-11 16:08:47 +02:00
|
|
|
let stories = req.keys();
|
|
|
|
stories = stories.sort();
|
|
|
|
|
2017-01-12 16:00:44 +02:00
|
|
|
stories.forEach(story => req(story));
|
2017-01-11 16:08:47 +02:00
|
|
|
|
|
|
|
// Fallback to stories/index.js file for anything that
|
|
|
|
// hasn't been moved
|
2016-12-08 14:08:04 +02:00
|
|
|
require('../stories');
|
|
|
|
}
|
|
|
|
|
|
|
|
configure(loadStories, module);
|