-
Notifications
You must be signed in to change notification settings - Fork 434
/
config.js
61 lines (51 loc) · 1.55 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
import React from 'react';
import { addDecorator, addParameters, configure } from '@storybook/react';
import { withA11y } from '@storybook/addon-a11y';
import { action } from '@storybook/addon-actions';
import {
global as designSystemGlobal,
loadFontsForStorybook,
styles,
} from '@storybook/design-system';
import 'storybook-chromatic';
const { GlobalStyle } = designSystemGlobal;
addParameters({
options: { panelPosition: 'bottom' },
viewport: {
viewports: [
{
name: 'Design system breakpoint',
styles: {
width: `${styles.breakpoint - 1}px`,
height: '768px',
},
},
],
},
});
// Gatsby's Link overrides:
// Gatsby defines a global called ___loader to prevent its method calls from creating console errors you override it here
global.___loader = {
enqueue: () => {},
hovering: () => {},
};
// Gatsby internal mocking to prevent unnecessary errors in storybook testing environment
global.__PATH_PREFIX__ = '';
// This is to utilized to override the window.___navigate method Gatsby defines and uses to report what path a Link would be taking us to if it wasn't inside a storybook
window.___navigate = pathname => {
action('NavigateTo:')(pathname);
};
// automatically import all files ending in *.stories.js
const req = require.context('../src', true, /\.stories\.js$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}
configure(loadStories, module);
addDecorator(withA11y);
addDecorator(story => (
<>
<GlobalStyle />
{story()}
</>
));
loadFontsForStorybook();