Norbert de Langen efbf470d6a
Merge branch 'next' into tech/overhaul-ui
# Conflicts:
#	CHANGELOG.md
#	addons/actions/package.json
#	addons/backgrounds/package.json
#	addons/notes/package.json
#	addons/storyshots/storyshots-core/package.json
#	addons/storyshots/storyshots-puppeteer/package.json
#	examples/cra-kitchen-sink/.storybook/config.js
#	examples/cra-kitchen-sink/src/stories/index.stories.js
#	lib/addons/package.json
#	lib/channel-websocket/package.json
#	lib/components/package.json
#	lib/components/src/addon_panel/__snapshots__/index.stories.storyshot
#	lib/components/src/header/__snapshots__/header.stories.storyshot
#	lib/components/src/layout/__snapshots__/index.stories.storyshot
#	lib/components/src/theme.js
#	lib/ui/package.json
#	lib/ui/src/modules/ui/components/stories_panel/__snapshots__/index.stories.storyshot
#	lib/ui/src/modules/ui/components/stories_panel/__snapshots__/text_filter.stories.storyshot
#	lib/ui/src/modules/ui/components/stories_panel/stories_tree/__snapshots__/index.stories.storyshot
#	lib/ui/src/modules/ui/configs/handle_routing.js
#	yarn.lock
2018-11-28 17:01:29 +01:00

95 lines
2.3 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 { withCssResources } from '@storybook/addon-cssresources';
import 'react-chromatic/storybook-addon';
import addHeadWarning from './head-warning';
import extraViewports from './extra-viewports.json';
if (process.env.NODE_ENV === 'development') {
if (!process.env.DOTENV_DEVELOPMENT_DISPLAY_WARNING) {
addHeadWarning('Dotenv development file not loaded');
}
if (!process.env.STORYBOOK_DISPLAY_WARNING) {
addHeadWarning('Global storybook env var not loaded');
}
if (process.env.DISPLAY_WARNING) {
addHeadWarning('Global non-storybook env var loaded');
}
}
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() : <Reset>{story()}</Reset>));
addDecorator(
withCssResources({
cssresources: [
{
name: `bluetheme`,
code: `<style>body {
background-color: lightblue;
}</style>`,
picked: false,
},
],
})
);
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);