2018-05-15 23:52:57 +02:00
|
|
|
import React from 'react';
|
2019-11-14 16:34:44 +01:00
|
|
|
import { 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-08-05 16:50:42 +08:00
|
|
|
import { DocsPage } from '@storybook/addon-docs/blocks';
|
2018-05-15 23:52:57 +02: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);
|
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: {
|
2019-11-13 17:57:51 +08:00
|
|
|
showRoots: true,
|
2019-06-18 16:14:54 +08:00
|
|
|
theme: themes.light, // { base: 'dark', brandTitle: 'Storybook!' },
|
2019-07-30 16:39:03 +02:00
|
|
|
storySort: (a, b) =>
|
2019-12-19 00:23:06 +08:00
|
|
|
a[1].kind === b[1].kind ? 0 : a[1].id.localeCompare(b[1].id, undefined, { numeric: true }),
|
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' },
|
|
|
|
],
|
2019-08-27 15:40:06 +08:00
|
|
|
docs: {
|
2019-11-17 11:03:26 -08:00
|
|
|
page: () => <DocsPage subtitleSlot={({ selectedKind }) => `Subtitle: ${selectedKind}`} />,
|
2019-08-27 15:40:06 +08:00
|
|
|
},
|
2018-02-26 00:00:28 +01:00
|
|
|
});
|
2020-02-17 16:59:08 +11:00
|
|
|
|
|
|
|
export const parameters = {
|
|
|
|
exportedParameter: 'exportedParameter',
|
|
|
|
};
|