2018-05-15 23:52:57 +02:00
|
|
|
import React from 'react';
|
2019-07-26 23:10:07 +08:00
|
|
|
import { configure, addDecorator, addParameters } from '@storybook/react';
|
2019-03-20 18:00:29 +01:00
|
|
|
import { Global, ThemeProvider, themes, createReset, convert } from '@storybook/theming';
|
2018-12-10 19:27:12 +01:00
|
|
|
import { withCssResources } from '@storybook/addon-cssresources';
|
2019-03-04 13:00:17 +08:00
|
|
|
import { withA11y } from '@storybook/addon-a11y';
|
2018-12-20 12:14:25 +11:00
|
|
|
import { withNotes } from '@storybook/addon-notes';
|
2018-05-15 23:52:57 +02:00
|
|
|
|
2019-01-18 15:37:08 +11:00
|
|
|
import 'storybook-chromatic';
|
2018-12-10 19:27:12 +01:00
|
|
|
|
2018-01-06 22:49:40 +03:00
|
|
|
import addHeadWarning from './head-warning';
|
|
|
|
|
2018-10-14 17:39:35 +02:00
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
if (!process.env.DOTENV_DEVELOPMENT_DISPLAY_WARNING) {
|
2018-12-29 19:50:44 +01:00
|
|
|
addHeadWarning('dotenv-env', 'Dotenv development file not loaded');
|
2018-10-14 17:39:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!process.env.STORYBOOK_DISPLAY_WARNING) {
|
2018-12-29 19:50:44 +01:00
|
|
|
addHeadWarning('env-glob', 'Global storybook env var not loaded');
|
2018-10-14 17:39:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (process.env.DISPLAY_WARNING) {
|
2018-12-29 19:50:44 +01:00
|
|
|
addHeadWarning('env-extra', 'Global non-storybook env var loaded');
|
2018-10-14 17:39:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-29 19:50:44 +01:00
|
|
|
addHeadWarning('preview-head-not-loaded', 'Preview head not loaded');
|
|
|
|
addHeadWarning('dotenv-file-not-loaded', 'Dotenv file not loaded');
|
2017-12-27 10:39:31 +01:00
|
|
|
|
2018-12-10 19:27:12 +01:00
|
|
|
addDecorator(withCssResources);
|
2019-03-04 13:00:17 +08:00
|
|
|
addDecorator(withA11y);
|
2018-12-20 12:14:25 +11:00
|
|
|
addDecorator(withNotes);
|
2017-11-27 13:48:46 +11:00
|
|
|
|
2019-02-20 01:45:52 +01:00
|
|
|
addDecorator(storyFn => (
|
2019-03-04 21:05:01 +01:00
|
|
|
<ThemeProvider theme={convert(themes.light)}>
|
2019-02-14 15:04:55 +01:00
|
|
|
<Global styles={createReset} />
|
2019-02-20 01:45:52 +01:00
|
|
|
{storyFn()}
|
2018-12-29 19:50:44 +01:00
|
|
|
</ThemeProvider>
|
|
|
|
));
|
2018-05-15 23:52:57 +02:00
|
|
|
|
2018-12-06 12:02:21 +01:00
|
|
|
addParameters({
|
2019-02-21 21:28:32 +01:00
|
|
|
a11y: {
|
2019-03-06 17:40:33 +01:00
|
|
|
config: {},
|
2019-02-21 21:28:32 +01:00
|
|
|
options: {
|
|
|
|
checks: { 'color-contrast': { options: { noScroll: true } } },
|
|
|
|
restoreScroll: true,
|
|
|
|
},
|
|
|
|
},
|
2018-12-10 19:27:12 +01:00
|
|
|
options: {
|
|
|
|
hierarchySeparator: /\/|\./,
|
|
|
|
hierarchyRootSeparator: '|',
|
2019-06-18 16:14:54 +08:00
|
|
|
theme: themes.light, // { base: 'dark', brandTitle: 'Storybook!' },
|
2018-12-10 19:27:12 +01:00
|
|
|
},
|
2019-02-14 15:04:55 +01:00
|
|
|
backgrounds: [
|
2019-03-04 21:05:01 +01:00
|
|
|
{ name: 'storybook app', value: themes.light.appBg, default: true },
|
2019-02-14 15:04:55 +01:00
|
|
|
{ name: 'light', value: '#eeeeee' },
|
|
|
|
{ name: 'dark', value: '#222222' },
|
|
|
|
],
|
2018-02-26 00:00:28 +01:00
|
|
|
});
|
|
|
|
|
2019-07-26 23:10:07 +08:00
|
|
|
configure(
|
2019-07-22 14:00:32 +08:00
|
|
|
[
|
|
|
|
require.context('../../lib/ui/src', true, /\.stories\.(js|tsx?|mdx)$/),
|
|
|
|
require.context('../../lib/components/src', true, /\.stories\.(js|tsx?|mdx)$/),
|
2019-07-22 14:27:23 +08:00
|
|
|
require.context('./stories', true, /\.stories\.(js|tsx?|mdx)$/),
|
2019-07-22 14:00:32 +08:00
|
|
|
],
|
|
|
|
module
|
|
|
|
);
|