Skip to content

Commit 60703b4

Browse files
committed
fix snapshots
1 parent a3ff097 commit 60703b4

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

packages/components/.storybook/config.tsx

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
2-
2+
import isChromatic from 'storybook-chromatic/isChromatic';
33
import { withKnobs } from '@storybook/addon-knobs';
44
import { withA11y } from '@storybook/addon-a11y';
55
import { addDecorator, addParameters, configure } from '@storybook/react';
66
import { themes } from '@storybook/theming';
7-
import { createGlobalStyle } from 'styled-components';
7+
import { createGlobalStyle, ThemeProvider } from 'styled-components';
88
// @ts-ignore
99
import global from '@codesandbox/common/lib/global.css';
1010
import { makeTheme, getThemes } from '../src/components/ThemeProvider';
@@ -48,23 +48,34 @@ const GlobalStyle = createGlobalStyle`
4848
4949
}
5050
`;
51-
52-
export const withGlobal = (cb: any) => (
53-
<>
54-
<GlobalStyle />
55-
{cb()}
56-
</>
57-
);
58-
5951
const allThemes = getThemes();
6052
const vsCodeThemes = allThemes.map(b => makeTheme(b, b.name));
53+
6154
const blackCodesandbox = vsCodeThemes.find(
6255
theme => theme.name === 'CodeSandbox Black'
6356
);
57+
console.log(isChromatic());
58+
if (!isChromatic()) {
59+
const withGlobal = (cb: any) => (
60+
<>
61+
<GlobalStyle />
62+
{cb()}
63+
</>
64+
);
65+
66+
const rest = vsCodeThemes.filter(theme => theme.name !== 'CodeSandbox Black');
67+
addDecorator(withGlobal);
68+
addDecorator(withThemesProvider([blackCodesandbox, ...rest]));
69+
} else {
70+
const withGlobal = (cb: any) => (
71+
<ThemeProvider theme={makeTheme(blackCodesandbox, 'default')}>
72+
<GlobalStyle />
73+
{cb()}
74+
</ThemeProvider>
75+
);
6476

65-
const rest = vsCodeThemes.filter(theme => theme.name !== 'CodeSandbox Black');
66-
addDecorator(withGlobal);
67-
addDecorator(withThemesProvider([blackCodesandbox, ...rest]));
77+
addDecorator(withGlobal);
78+
}
6879
addDecorator(withA11y);
6980
addDecorator(withKnobs);
7081
addParameters({ viewport: { viewports } });

0 commit comments

Comments
 (0)