generated from wednesday-solutions/react-template
-
Notifications
You must be signed in to change notification settings - Fork 13
/
config.js
36 lines (30 loc) · 1.07 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
import React from 'react';
import { configure } from '@storybook/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 { translationMessages, appLocales, DEFAULT_LOCALE } from '../app/i18n.ts';
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);