mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-20 05:02:37 +08:00
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
import React from 'react';
|
|
import ThemeProvider from '@emotion/provider';
|
|
import { configure, addDecorator } from '@storybook/react';
|
|
import { themes } from '@storybook/components';
|
|
import { withOptions } from '@storybook/addon-options';
|
|
import { configureViewport, INITIAL_VIEWPORTS } from '@storybook/addon-viewport';
|
|
|
|
import 'react-chromatic/storybook-addon';
|
|
import addHeadWarning from './head-warning';
|
|
import extraViewports from './extra-viewports.json';
|
|
|
|
addHeadWarning('Preview head not loaded', 'preview-head-not-loaded');
|
|
addHeadWarning('Dotenv file not loaded', 'dotenv-file-not-loaded');
|
|
|
|
addDecorator(
|
|
withOptions({
|
|
hierarchySeparator: /\/|\./,
|
|
hierarchyRootSeparator: /\|/,
|
|
theme: themes.dark,
|
|
})
|
|
);
|
|
|
|
addDecorator(
|
|
(story, { kind }) =>
|
|
kind === 'Core|Errors' ? (
|
|
story()
|
|
) : (
|
|
<ThemeProvider theme={themes.normal}>{story()}</ThemeProvider>
|
|
)
|
|
);
|
|
|
|
configureViewport({
|
|
viewports: {
|
|
...INITIAL_VIEWPORTS,
|
|
...extraViewports,
|
|
},
|
|
});
|
|
|
|
function importAll(req) {
|
|
req.keys().forEach(filename => req(filename));
|
|
}
|
|
|
|
function loadStories() {
|
|
let req;
|
|
req = require.context('../../lib/ui/src', true, /\.stories\.js$/);
|
|
importAll(req);
|
|
|
|
req = require.context('../../lib/components/src', true, /\.stories\.js$/);
|
|
importAll(req);
|
|
|
|
req = require.context('./stories', true, /\.stories\.js$/);
|
|
importAll(req);
|
|
}
|
|
|
|
configure(loadStories, module);
|