generated from wednesday-solutions/react-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
44 lines (37 loc) · 1.24 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { configure } from '@storybook/react';
import '@formatjs/intl-relativetimeformat/polyfill';
import '@formatjs/intl-relativetimeformat/dist/locale-data/en';
import React from 'react';
import { addDecorator } from '@storybook/react';
import { withKnobs } from '@storybook/addon-knobs';
import StoryRouter from 'storybook-router';
import { withSmartKnobs } from 'storybook-addon-smart-knobs';
import { setIntlConfig, withIntl } from 'storybook-addon-intl';
// import enLocaleData from 'react-intl/locale-data/en';
import {
translationMessages,
appLocales,
DEFAULT_LOCALE
} from '../app/i18n.js';
Object.values = obj => Object.keys(obj).map(key => obj[key]);
addDecorator(withSmartKnobs);
addDecorator(withKnobs);
addDecorator(StoryRouter());
const getMessages = locale => translationMessages[locale];
setIntlConfig({
locales: appLocales,
defaultLocale: DEFAULT_LOCALE,
getMessages
});
addDecorator(withIntl);
// automatically import all files ending in *.stories.js
function requireAll(requireContext) {
return requireContext.keys().map(key => {
return requireContext;
});
}
function loadStories() {
const req = require.context('../app/components/', true, /^.*\.stories$/);
return requireAll(req);
}
configure(loadStories(), module);