mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-20 05:02:37 +08:00
# Conflicts: # addons/actions/package.json # addons/options/README.md # lib/components/package.json # lib/core/package.json # lib/ui/package.json # lib/ui/src/modules/api/actions/api.js # lib/ui/src/modules/api/actions/api.test.js # lib/ui/src/modules/api/index.js # lib/ui/src/modules/shortcuts/actions/shortcuts.js # lib/ui/src/modules/shortcuts/actions/shortcuts.test.js # lib/ui/src/modules/shortcuts/index.js # yarn.lock
66 lines
1.6 KiB
JavaScript
66 lines
1.6 KiB
JavaScript
import React from 'react';
|
|
import ThemeProvider from '@emotion/provider';
|
|
import styled from '@emotion/styled';
|
|
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,
|
|
})
|
|
);
|
|
|
|
const Reset = styled.div(({ theme }) => ({
|
|
fontFamily: theme.mainTextFace,
|
|
color: theme.mainTextColor,
|
|
WebkitFontSmoothing: 'antialiased',
|
|
fontSize: theme.mainTextSize,
|
|
}));
|
|
|
|
addDecorator(
|
|
(story, { kind }) =>
|
|
kind === 'Core|Errors' ? (
|
|
story()
|
|
) : (
|
|
<ThemeProvider theme={themes.dark}>
|
|
<Reset>{story()}</Reset>
|
|
</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);
|