-
Notifications
You must be signed in to change notification settings - Fork 130
/
config.js
87 lines (76 loc) · 1.98 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React from 'react';
import { configure, addDecorator, addParameters } from '@storybook/react';
import { withKnobs } from '@storybook/addon-knobs';
import { withA11y } from '@storybook/addon-a11y';
import { ThemeProvider } from 'emotion-theming';
import styled from '@emotion/styled';
import requireContext from 'require-context.macro';
import { theme as themes, BaseStyles } from '../src';
import { theme, components } from './util/theme';
import { sortStories } from './util/story-helpers';
const { circuit } = themes;
// Add group and story names to the sort order to explicitly order them.
// Items that are not included in the list are shown below the sorted items.
const SORT_ORDER = {
Introduction: [
'Welcome',
'Developers',
'Designers',
'Contributing',
'Code of Conduct'
],
Styles: ['Static Styles', 'Theme'],
Typography: ['Heading', 'SubHeading', 'Text'],
Layout: [],
Forms: [],
Components: [],
Icons: []
};
addParameters({
options: {
storySort: sortStories(SORT_ORDER),
theme,
isFullscreen: false,
panelPosition: 'bottom',
isToolshown: true
},
docs: {
components
}
});
const Story = styled.div`
display: flex;
flex-direction: column;
gap: 1rem;
justify-content: center;
align-items: center;
min-height: 100vh;
.sbdocs & {
min-height: auto;
}
`;
const withStoryStyles = storyFn => {
return <Story>{storyFn()}</Story>;
};
const withThemeProvider = storyFn => (
<ThemeProvider theme={circuit}>
<BaseStyles />
{storyFn()}
</ThemeProvider>
);
addDecorator(withA11y);
addDecorator(withKnobs);
// These decorators need to be disabled for StoryShots to work.
if (!__TEST__) {
const withTests = require('./util/withTests');
addDecorator(withTests);
addDecorator(withStoryStyles);
}
addDecorator(withThemeProvider);
configure(
[
requireContext('../src', true, /\.(stories|story)\.(js|ts|tsx|mdx)$/),
requireContext('../docs', true, /\.(stories|story)\.(js|ts|tsx|mdx)$/)
],
module
);