Skip to content

Commit fdc0c33

Browse files
committed
update editor background color on dark theme
1 parent f53538a commit fdc0c33

File tree

3 files changed

+75
-5
lines changed

3 files changed

+75
-5
lines changed

package-lock.json

Lines changed: 33 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@codemirror/commands": "^6.2.4",
1313
"@codemirror/lang-sql": "^6.4.1",
1414
"@codemirror/view": "^6.11.1",
15+
"@lezer/highlight": "^1.1.4",
1516
"@neondatabase/serverless": "^0.4.3",
1617
"@radix-ui/react-accordion": "^1.1.1",
1718
"@radix-ui/react-dialog": "^1.0.3",
@@ -20,6 +21,7 @@
2021
"@tanstack/react-query": "^4.29.5",
2122
"@tanstack/react-table": "^8.9.1",
2223
"@uiw/codemirror-theme-github": "^4.19.16",
24+
"@uiw/codemirror-themes": "^4.20.2",
2325
"@uiw/react-codemirror": "^4.19.16",
2426
"@upstash/ratelimit": "^0.4.3",
2527
"@upstash/redis": "^1.20.6",

src/components/editor.tsx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,45 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
2020
import { useTheme } from 'next-themes';
2121
import { toast } from 'react-hot-toast';
2222
import { Icon } from './shared/icon';
23+
import createTheme from '@uiw/codemirror-themes';
24+
import { tags as t } from '@lezer/highlight';
25+
26+
const myTheme = createTheme({
27+
theme: 'dark',
28+
settings: {
29+
background: '#151718',
30+
foreground: '#c9d1d9',
31+
caret: '#c9d1d9',
32+
selection: '#003d73',
33+
selectionMatch: '#003d73',
34+
lineHighlight: '#36334280',
35+
36+
gutterBackground: 'transparent',
37+
gutterForeground: 'rgb(155, 161, 166,0.6)',
38+
},
39+
styles: [
40+
{ tag: [t.standard(t.tagName), t.tagName], color: '#7ee787' },
41+
{ tag: [t.comment, t.bracket], color: '#8b949e' },
42+
{ tag: [t.className, t.propertyName], color: '#d2a8ff' },
43+
{
44+
tag: [t.variableName, t.attributeName, t.number, t.operator],
45+
color: '#79c0ff',
46+
},
47+
{
48+
tag: [t.keyword, t.typeName, t.typeOperator, t.typeName],
49+
color: '#ff7b72',
50+
},
51+
{ tag: [t.string, t.meta, t.regexp], color: '#a5d6ff' },
52+
{ tag: [t.name, t.quote], color: '#7ee787' },
53+
{ tag: [t.heading], color: '#d2a8ff', fontWeight: 'bold' },
54+
{ tag: [t.emphasis], color: '#d2a8ff', fontStyle: 'italic' },
55+
{ tag: [t.deleted], color: '#ffdcd7', backgroundColor: 'ffeef0' },
56+
{ tag: [t.atom, t.bool, t.special(t.variableName)], color: '#ffab70' },
57+
{ tag: t.link, textDecoration: 'underline' },
58+
{ tag: t.strikethrough, textDecoration: 'line-through' },
59+
{ tag: t.invalid, color: '#f97583' },
60+
],
61+
});
2362

2463
export const Editor = () => {
2564
const { resolvedTheme } = useTheme();
@@ -59,7 +98,7 @@ export const Editor = () => {
5998
return (
6099
<>
61100
<CodeMirror
62-
theme={resolvedTheme === 'dark' ? githubDark : githubLight}
101+
theme={resolvedTheme === 'dark' ? myTheme : githubLight}
63102
value={query}
64103
basicSetup={{
65104
defaultKeymap: false,

0 commit comments

Comments
 (0)