Newer
Older
import { configure, addDecorator } from '@storybook/react'
esikkala
committed
import React from 'react'
import { createStore } from 'redux'
import { Provider } from 'react-redux'
import { Router } from 'react-router-dom'
import { createBrowserHistory } from 'history'
import intl from 'react-intl-universal'
import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles'
import deepPurple from '@material-ui/core/colors/deepPurple'
import localeEN from '../src/client/translations/sampo/localeEN'
import localeFI from '../src/client/translations/sampo/localeFI'
import localeSV from '../src/client/translations/sampo/localeSV'
import reducer from '../src/client/reducers'
import '../src/client/index.css'
const loaderFn = () => {
const allExports = [require('./welcome.stories.js')];
const req = require.context('../src/client/components', true, /\.stories\.js$/);
req.keys().forEach(fname => allExports.push(req(fname)));
return allExports;
};
configure(loaderFn, module);
esikkala
committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const store = createStore(reducer)
intl.init({
currentLocale: 'en',
locales: {
en: localeEN,
fi: localeFI,
sv: localeSV
}
})
const theme = createMuiTheme({
palette: {
primary: deepPurple
},
overrides: {
MuiTooltip: {
tooltip: {
fontSize: '1 rem'
}
},
MuiExpansionPanel: {
root: {
'&$expanded': {
marginTop: 8,
marginBottom: 8
}
}
},
MuiButton: {
endIcon: {
marginLeft: 0
}
}
}
})
addDecorator(Story => (
<Provider store={store}>
<Router history={createBrowserHistory()}>
<MuiThemeProvider theme={theme}>
<Story />
</MuiThemeProvider>
</Router>
</Provider>
))