Add injectGlobal to storybook config to fix fonts and wrap all components in base component
This commit is contained in:
parent
1f2f8a6965
commit
0813b5c9fb
@ -1,6 +1,35 @@
|
|||||||
const { configure } = require('@kadira/storybook');
|
const React = require('react');
|
||||||
|
const { configure, addDecorator } = require('@kadira/storybook');
|
||||||
|
|
||||||
const req = require.context('../src/components', true, /story.js$/)
|
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>
|
||||||
|
));
|
||||||
|
|
||||||
function loadStories() {
|
function loadStories() {
|
||||||
let stories = req.keys();
|
let stories = req.keys();
|
||||||
|
Loading…
Reference in New Issue
Block a user