Skip to content

Commit 4db7e94

Browse files
committed
Dark mode the diffs
1 parent a48fa53 commit 4db7e94

File tree

4 files changed

+131
-42
lines changed

4 files changed

+131
-42
lines changed

src/components/common/Diff/Diff.js

Lines changed: 79 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ const Container = styled.div`
2121
border-radius: 3px;
2222
margin-bottom: 16px;
2323
margin-top: 16px;
24+
color: ${({ theme }) => theme.text};
2425
`
2526

2627
const More = styled.div`
27-
background-color: #f1f8ff;
2828
margin-left: 30px;
2929
padding-left: 4px;
30-
color: '#1b1f23b3';
3130
`
3231

3332
const Decoration = styled(DiffDecoration)`
34-
background-color: #dbedff;
33+
background-color: ${({ theme }) => theme.diff.decorationContentBackground};
34+
color: ${({ theme }) => theme.diff.decorationContent};
3535
`
3636

3737
const DiffView = styled(RDiff)`
@@ -44,31 +44,19 @@ const DiffView = styled(RDiff)`
4444
monospace;
4545
}
4646
47-
td.diff-gutter {
48-
color: rgba(27, 31, 35, 0.3);
49-
padding: 0;
50-
text-align: center;
51-
font-size: 12px;
52-
cursor: auto;
53-
}
54-
5547
td.diff-gutter .diff-line-normal {
56-
background-color: ${({ theme }) => theme.lightGreenBackground};
48+
background-color: ${({ theme }) => theme.gutterInsertBackground};
5749
border-color: ${({ theme }) => theme.greenBorder};
5850
}
5951
6052
td.diff-gutter:hover {
6153
cursor: pointer;
62-
color: rgba(27, 31, 35, 0.6);
54+
color: ${({ theme }) => theme.textHover};
6355
}
6456
6557
td.diff-code {
6658
font-size: 12px;
67-
color: #24292e;
68-
}
69-
70-
td.diff-code-insert .diff-code-edit {
71-
background-color: ${({ theme }) => theme.darkGreenBackground};
59+
color: ${({ theme }) => theme.text};
7260
}
7361
7462
td.diff-gutter-omit:before {
@@ -79,6 +67,79 @@ const DiffView = styled(RDiff)`
7967
td.diff-widget-content {
8068
padding: 0;
8169
}
70+
71+
// From diff global
72+
.diff {
73+
background-color: ${({ theme }) => theme.diff.backgroundColor};
74+
color: ${({ theme }) => theme.diff.text};
75+
tab-size: 4;
76+
hyphens: none;
77+
}
78+
79+
.diff::selection {
80+
background-color: ${({ theme }) => theme.diff.selectionMackground};
81+
}
82+
83+
.diff-decoration {
84+
line-height: 2;
85+
font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier,
86+
monospace;
87+
background-color: ${({ theme }) => theme.diff.decorationBackground};
88+
}
89+
90+
.diff-decoration-content {
91+
padding-left: 0.5em;
92+
background-color: ${({ theme }) => theme.diff.contentBackground};
93+
color: ${({ theme }) => theme.diff.decorationContent};
94+
}
95+
96+
.diff-gutter {
97+
padding: 0;
98+
text-align: center;
99+
font-size: 12px;
100+
cursor: auto;
101+
}
102+
103+
.diff-gutter-insert {
104+
background-color: ${({ theme }) => theme.diff.gutterInsertBackground};
105+
}
106+
107+
.diff-gutter-delete {
108+
background-color: ${({ theme }) => theme.diff.gutterDeleteBackground};
109+
}
110+
111+
.diff-gutter-selected {
112+
background-color: ${({ theme }) => theme.diff.gutterSelectedBackground};
113+
}
114+
115+
.diff-code-insert {
116+
background-color: ${({ theme }) => theme.diff.codeInsertBackground};
117+
}
118+
119+
.diff-code-edit {
120+
color: inherit;
121+
}
122+
123+
.diff-code-insert .diff-code-edit {
124+
background-color: ${({ theme }) => theme.diff.codeInsertEditBackground};
125+
}
126+
127+
.diff-code-delete {
128+
background-color: ${({ theme }) => theme.diff.codeDeleteBackground};
129+
}
130+
131+
.diff-code-delete .diff-code-edit {
132+
background-color: ${({ theme }) => theme.diff.codeDeleteEditBackground};
133+
}
134+
135+
.diff-code-selected {
136+
background-color: ${({ theme }) => theme.diff.codeSelectedBackground};
137+
}
138+
139+
.diff-decoration-gutter {
140+
background-color: ${({ theme }) => theme.diff.decorationGutterBackground};
141+
color: ${({ theme }) => theme.diff.decorationGutter};
142+
}
82143
`
83144

84145
// Diff will be collapsed by default if the file has been deleted or has more than 5 hunks

src/components/common/Diff/DiffHeader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ const CompleteDiffButton = styled(({ open, onClick, ...props }) =>
122122
&,
123123
&:hover,
124124
&:focus {
125-
color: ${({ isDiffCompleted }) =>
126-
isDiffCompleted ? '#52c41a' : '#24292e'};
125+
color: ${({ isDiffCompleted, theme }) =>
126+
isDiffCompleted ? '#52c41a' : theme.text};
127127
}
128128
`
129129

src/components/pages/Home.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, useEffect, useDeferredValue } from 'react'
22
import styled from '@emotion/styled'
3-
import { ThemeProvider, Global, css } from '@emotion/react'
3+
import { ThemeProvider } from '@emotion/react'
44
import { Card, Input, Typography, ConfigProvider, theme } from 'antd'
55
import GitHubButton from 'react-github-btn'
66
import ReactGA from 'react-ga'
@@ -194,16 +194,6 @@ const Home = () => {
194194
<ConfigProvider
195195
theme={{
196196
algorithm: isDarkMode ? darkAlgorithm : defaultAlgorithm,
197-
// components: {
198-
// Button: {
199-
// // colorPrimary: '#00b96b',
200-
// algorithm: true, // Enable algorithm
201-
// },
202-
// Input: {
203-
// colorPrimary: '#eb2f96',
204-
// algorithm: true, // Enable algorithm
205-
// },
206-
// },
207197
}}
208198
>
209199
<ThemeProvider theme={isDarkMode ? darkTheme : lightTheme}>

src/theme/index.js

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,67 @@ export const lightTheme = {
33
background: '#ffffff',
44

55
text: '#363537',
6-
// toggleBorder: '#FFF',
7-
// background: '#363537',
6+
textHover: 'rgba(27, 31, 35, 0.6)',
87
border: '#e8e8e8',
98
greenBorder: '#bef5cb',
109
yellowBorder: '#ffe58f',
11-
lightGreenBackground: '#cdffd8',
12-
darkGreenBackground: '#acf2bd',
13-
// Alternating Rows
10+
11+
diff: {
12+
decoration: '#dbedff',
13+
14+
// Color object from https://github.com/otakustay/react-diff-view/blob/master/site/components/DiffView/diff.global.less
15+
textColor: '#000',
16+
selectionBackground: '#b3d7ff',
17+
gutterInsertBackground: '#cdffd8',
18+
gutterDeleteBackground: '#fadde0',
19+
gutterSelectedBackground: '#fffce0',
20+
codeInsertBackground: '#eaffee',
21+
codeDeleteBackground: '#fdeff0',
22+
codeInsertEditBackground: '#acf2bd',
23+
codeDeleteEditBackground: '#f39ea2',
24+
codeSelectedBackground: '#fffce0',
25+
omitBackground: '#fafbfc',
26+
decorationGutterBackground: '#dbedff',
27+
decorationGutter: '#999',
28+
decorationContentBackground: '#dbedff',
29+
decorationContent: '#999',
30+
},
31+
32+
// Alternating Row Colors for Binary Download component
1433
rowEven: '#fafbfc',
1534
rowOdd: '#ffffff',
1635
}
1736
export const darkTheme = {
1837
body: '#363537',
1938
background: '#363537',
2039
text: '#FAFAFA',
21-
// toggleBorder: '#6B8096',
22-
// background: '#999',
40+
textHover: '#999',
2341
border: '#888',
2442
greenBorder: '#bef5cb',
2543
yellowBorder: '#ffe58f',
26-
lightGreenBackground: '#cdffd8',
27-
darkGreenBackground: '#acf2bd',
28-
// Alternating Rows
44+
45+
diff: {
46+
decoration: '#dbedff',
47+
48+
// Color object from https://github.com/otakustay/react-diff-view/blob/master/site/components/DiffView/diff.global.less
49+
textColor: '#fafafa',
50+
selectionBackground: '#5a5f80',
51+
gutterInsertBackground: '#082525',
52+
gutterDeleteBackground: '#2b1523',
53+
gutterSelectedBackground: '#5a5f80',
54+
codeInsertBackground: '#082525',
55+
codeDeleteBackground: '#2b1523',
56+
codeInsertEditBackground: '#00462f',
57+
codeDeleteEditBackground: '#4e2436',
58+
codeSelectedBackground: '#5a5f80',
59+
omitBackground: '#101120',
60+
decorationGutterBackground: '#222',
61+
decorationGutter: '#ababab',
62+
decorationContentBackground: '#222',
63+
decorationContent: '#ababab',
64+
},
65+
66+
// Alternating Row Colors for Binary Download component
2967
rowEven: '#363537',
30-
rowOdd: '#363537',
68+
rowOdd: '#222223',
3169
}

0 commit comments

Comments
 (0)