Skip to content

Commit 609d1ce

Browse files
authored
fix storybok (codesandbox#3926)
* fix storybok * clean styles * fix ts
1 parent 97a4c4f commit 609d1ce

File tree

6 files changed

+2706
-199
lines changed

6 files changed

+2706
-199
lines changed

packages/components/.storybook/config.tsx

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ import { withA11y } from '@storybook/addon-a11y';
55
import { addDecorator, addParameters, configure } from '@storybook/react';
66
import { themes } from '@storybook/theming';
77
import { createGlobalStyle, ThemeProvider } from 'styled-components';
8-
// @ts-ignore
9-
import global from './global.css';
108
import { makeTheme, getThemes } from '../src/components/ThemeProvider';
119
import { withThemesProvider } from './storybook-addon-styled-component-theme';
1210

11+
type Theme = {
12+
colors: any;
13+
name: string;
14+
};
15+
1316
const viewports = {
1417
mobile: {
1518
name: 'Mobile',
@@ -32,28 +35,43 @@ const viewports = {
3235
// new globals based on theme?
3336
// using sidebar as the styles for body for now 🤷
3437
const GlobalStyle = createGlobalStyle`
35-
${global};
38+
39+
3640
html body {
3741
font-family: 'Inter', sans-serif;
42+
-webkit-font-smoothing: auto;
43+
-moz-font-smoothing: auto;
44+
-moz-osx-font-smoothing: grayscale;
45+
-webkit-text-size-adjust: 100%;
46+
-webkit-tap-highlight-color: transparent;
47+
-webkit-touch-callout: none;
48+
font-smoothing: antialiased;
49+
text-rendering: optimizeLegibility;
50+
font-smooth: always;
51+
min-height: 100%;
52+
height: 100%;
53+
font-size: 16px;
3854
width: 400px;
3955
margin: 0;
40-
background-color: ${props =>
41-
// @ts-ignore
42-
props.theme.colors.sideBar.background} !important;
43-
color: ${props =>
44-
// @ts-ignore
45-
props.theme.colors.sideBar.foreground} !important;
56+
background-color: ${({ theme }: { theme: Theme }) =>
57+
theme.colors.sideBar.background};
58+
color: ${({ theme }: { theme: Theme }) => theme.colors.sideBar.foreground};
59+
4660
* {
4761
box-sizing: border-box;
4862
}
4963
64+
a {
65+
color: #40a9f3;
66+
}
67+
5068
}
5169
`;
5270
const allThemes = getThemes();
5371
const vsCodeThemes = allThemes.map(b => makeTheme(b, b.name));
5472

5573
const blackCodesandbox = vsCodeThemes.find(
56-
theme => theme.name === 'CodeSandbox Black'
74+
(theme: Theme) => theme.name === 'CodeSandbox Black'
5775
);
5876

5977
if (!isChromatic()) {
@@ -64,7 +82,9 @@ if (!isChromatic()) {
6482
</>
6583
);
6684

67-
const rest = vsCodeThemes.filter(theme => theme.name !== 'CodeSandbox Black');
85+
const rest = vsCodeThemes.filter(
86+
(theme: Theme) => theme.name !== 'CodeSandbox Black'
87+
);
6888
addDecorator(withGlobal);
6989
addDecorator(withThemesProvider([blackCodesandbox, ...rest]));
7090
} else {

packages/components/.storybook/global.css

Lines changed: 0 additions & 104 deletions
This file was deleted.

packages/components/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@
4444
"typeface-inter": "^3.11.2"
4545
},
4646
"devDependencies": {
47-
"@storybook/addon-a11y": "^5.2.8",
48-
"@storybook/addon-actions": "^5.2.8",
49-
"@storybook/addon-knobs": "^5.2.8",
50-
"@storybook/addon-storysource": "^5.2.8",
51-
"@storybook/addon-viewport": "^5.2.8",
47+
"@storybook/addon-a11y": "^5.3.18",
48+
"@storybook/addon-actions": "^5.3.18",
49+
"@storybook/addon-knobs": "^5.3.18",
50+
"@storybook/addon-storysource": "^5.3.18",
51+
"@storybook/addon-viewport": "^5.3.18",
5252
"@storybook/csf": "^0.0.1",
53-
"@storybook/react": "^5.2.8",
53+
"@storybook/react": "^5.3.18",
5454
"@types/color": "3.0.1",
5555
"@types/lodash": "^4.14.149",
5656
"@types/styled-components": "^4.4.1",
@@ -59,7 +59,7 @@
5959
"np": "^5.2.1",
6060
"rimraf": "^3.0.0",
6161
"storybook-addon-styled-component-theme": "^1.3.0",
62-
"storybook-chromatic": "^3.4.1",
62+
"storybook-chromatic": "^3.5.3",
6363
"typescript": "3.7.4"
6464
},
6565
"peerDependencies": {
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export * from './theme';
1+
import designLanguage from './theme';
2+
3+
export default designLanguage;

packages/components/src/utils/polyfill-theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import deepmerge from 'deepmerge';
99
import Color from 'color';
1010
import { object } from './dot';
11-
import designLanguage from '../design-language/theme';
11+
import designLanguage from '../design-language';
1212
import codesandboxBlack from '../themes/codesandbox-black';
1313
import codesandboxLight from '../themes/codesandbox-light.json';
1414

0 commit comments

Comments
 (0)