Skip to content

Commit ec8f667

Browse files
authored
feat: dark mode (#272)
1 parent 474779a commit ec8f667

36 files changed

+352
-204
lines changed

.storybook/main.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ module.exports = {
88
"@storybook/addon-links",
99
"@storybook/addon-essentials",
1010
"@storybook/addon-docs",
11+
"storybook-dark-mode"
1112
]
1213
}

.storybook/preview.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import React from 'react';
2+
import { themes } from '@storybook/theming';
3+
import { useDarkMode } from 'storybook-dark-mode';
4+
25

36
import ThemeProvider from '../src/theme/ThemeProvider';
47

8+
59
export const parameters = {
610
actions: { argTypesRegex: '^on[A-Z].*' },
711
layout: 'centered',
812
controls: { expanded: true },
9-
viewMode: 'docs' // `docs` is default tab, instead of canvas
13+
darkMode: {
14+
current: 'light',
15+
dark: { ...themes.dark, appBg: themes.dark.appBg },
16+
light: { ...themes.light, appBg: themes.light.appBg },
17+
}
1018
};
1119

1220
export const decorators = [
1321
(Story) => (
14-
<ThemeProvider>
22+
<ThemeProvider colorMode={useDarkMode() ? 'dark' : 'light'}>
1523
<Story />
1624
</ThemeProvider>
1725
),

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"react": "^16.14.0",
8080
"react-dom": "^16.14.0",
8181
"semantic-release": "^19.0.2",
82+
"storybook-dark-mode": "^1.1.0",
8283
"typescript": "^4.6.2",
8384
"yalc": "^1.0.0-pre.53"
8485
},

src/components/alternative-header/styles.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const wrapper = (topContent: boolean) =>
3737

3838
flexDirection: 'column',
3939

40-
boxShadow: topContent ? '0 -5px 0 #F5F5F5' : '',
40+
boxShadow: topContent ? '0 -5px 0 grayShade3' : '',
4141

4242
zIndex: 25,
4343

src/components/badge/utils/get-border-animation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const getBorderAnimation = (borderColor: string) => {
2020
fontSize: '12px',
2121
fontWeight: '500',
2222
borderRadius: '1px',
23-
color: '#f2994a',
23+
color: 'orange',
2424
':before': {
2525
content: "''",
2626
position: 'absolute',

src/components/box/Box.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React, { FC, forwardRef } from 'react';
2+
import { Box as RebassBox, BoxProps } from 'rebass';
3+
4+
export interface Props extends Omit<BoxProps, 'css'> {}
5+
6+
export const Box: FC<Props> = forwardRef(({ children, ...rest }, ref) => (
7+
<RebassBox ref={ref} {...rest}>
8+
{children}
9+
</RebassBox>
10+
));

src/components/box/index.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { Box } from './Box';
2+
3+
export type { Props as BoxProps } from './Box';

src/components/code-input/index.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Default.argTypes = argTypes;
100100
Default.args = {
101101
label: 'Label',
102102
mode: 'javascript',
103-
value: 'const a = 100;',
103+
value: 'const a = 100;\nconst b = 120;',
104104
tooltipInfo: 'some tooltip',
105105
onChange: action('Input change'),
106106
};

src/components/code-input/index.styles.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ const getStyles = () => ({
22
'.react-codemirror2': {
33
height: '100%',
44
'.CodeMirror': {
5-
background: '#F5F5F5 !important',
5+
background: '#grayShade3 !important',
66
height: '100%',
77
},
8-
'.CodeMirror-gutter': {
9-
color: 'gray',
10-
backgroundColor: 'grayShade2',
11-
},
128
},
139
});
1410

src/components/code-input/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import 'codemirror/mode/javascript/javascript';
88
import 'codemirror/mode/yaml/yaml';
99
import 'codemirror/mode/python/python';
1010
import 'codemirror/mode/sql/sql';
11-
// Note for dark-mode, good theme candidates: shadowbox, tomorrow-night-bright, dracula
12-
import 'codemirror/theme/yeti.css';
11+
12+
import 'codemirror/theme/darcula.css';
1313

1414
// Components
1515
import Label, { LabelProps } from '../label';
@@ -85,7 +85,7 @@ const CodeInput: FC<InputProps> = forwardRef(
8585
mode === 'javascript'
8686
? { name: mode, json: true }
8787
: { name: mode },
88-
theme: 'yeti',
88+
theme: 'darcula',
8989
lineNumbers: true,
9090
readOnly,
9191
}}

src/components/code/index.tsx

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { FC, useState } from 'react';
22
import { Box, FlexProps, Flex } from 'rebass';
33
import SyntaxHighlighter from 'react-syntax-highlighter';
4-
import { useTheme } from '../../theme/theme';
54
import Button from '../button';
65
import ExpandViewer from '../expand-viewer';
76

@@ -15,6 +14,7 @@ import Value from '../typography/value';
1514
import { copyToClipboard, saveToFile } from '../../utils';
1615
import { PopupProps } from '../popup';
1716
import { GetIcon, IconName } from '../icon';
17+
import { hybrid } from 'react-syntax-highlighter/dist/esm/styles/hljs';
1818

1919
const CONTENT_UPPER_BOUND = 12;
2020

@@ -122,8 +122,6 @@ const CodeSnippet: FC<CodeSnippetProps> = ({
122122
maxHeightOfCode,
123123
...props
124124
}) => {
125-
const theme = useTheme();
126-
127125
return (
128126
<Flex width="100%" sx={styles} height="100%">
129127
<Flex width="100%" sx={codeHeaderStyles}>
@@ -149,12 +147,10 @@ const CodeSnippet: FC<CodeSnippetProps> = ({
149147
p={0}
150148
>
151149
<SyntaxHighlighter
150+
style={hybrid}
152151
wrapLongLines={wrapLongLines}
153152
showLineNumbers={showLineNumbers}
154-
lineNumberStyle={{
155-
...lineNumberStyles,
156-
background: theme.colors.grayShade1,
157-
}}
153+
lineNumberStyle={lineNumberStyles}
158154
language={language}
159155
customStyle={{
160156
...boxStyles,

src/components/datepicker/datepicker.styles.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { SxStyleProp } from 'rebass';
33
export default (align: 'left' | 'right') =>
44
({
55
'.react-datepicker': {
6-
boxShadow: '0px 0px 15px rgba(0, 0, 0, 0.25)',
6+
boxShadow: 'notification',
77
borderRadius: 'initial',
88
},
99

src/components/flex/Flex.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React, { FC, forwardRef } from 'react';
2+
import { Flex as RebassFlex, FlexProps } from 'rebass';
3+
4+
export interface Props extends Omit<FlexProps, 'css'> {}
5+
6+
export const Flex: FC<Props> = forwardRef(({ children, ...rest }, ref) => (
7+
<RebassFlex ref={ref} {...rest}>
8+
{children}
9+
</RebassFlex>
10+
));

src/components/flex/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { Flex } from './Flex';
2+
3+
export type { Props as FlexProps } from './Flex';

src/components/graphs/split-graph/split-graph.styles.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export const progressBarStyles = (
88
bg: color,
99
width: `${percent}%`,
1010
marginRight: '2px',
11-
border: isSelected ? '1px solid #272727' : null,
11+
border: isSelected ? '1px solid' : null,
12+
borderColor: 'black',
1213
});
1314

1415
export const circleStyles = (
@@ -19,5 +20,6 @@ export const circleStyles = (
1920
width: '10px',
2021
height: '10px',
2122
borderRadius: '50%',
22-
border: isSelected ? '1px solid #272727' : null,
23+
border: isSelected ? '1px solid' : null,
24+
borderColor: 'black',
2325
});

src/components/icon/get-icon.stories.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,13 @@ Default.argTypes = {
106106
'labels.orange',
107107
'labels.purple',
108108
'labels.yellow',
109-
'labels.yellowLight',
109+
'labels.yellowShade2',
110110
'labels.green',
111-
'labels.skyblue',
112-
'labels.darkblue',
113-
'labels.lightblue',
111+
'labels.blueShade1',
112+
'labels.blueShade2',
114113
'labels.blue',
115-
'labels.redShade3',
116-
'labels.orangeShade3',
114+
'labels.redShade2',
115+
'labels.orangeShade2',
117116
],
118117
control: {
119118
type: 'select',

0 commit comments

Comments
 (0)