-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
39 lines (33 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
import { configure } from '@storybook/react';
import '@formatjs/intl-relativetimeformat/polyfill';
import '@formatjs/intl-relativetimeformat/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(withKnobs);
addDecorator(withSmartKnobs);
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);