Skip to content

Commit 82e931c

Browse files
committed
style(vscode): add vscodeDarkInit method. #409
1 parent d1150da commit 82e931c

File tree

2 files changed

+96
-77
lines changed

2 files changed

+96
-77
lines changed

themes/vscode/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@
1616
npm install @uiw/codemirror-theme-vscode --save
1717
```
1818

19+
```jsx
20+
import { vscodeDark, vscodeDarkInit } from '@uiw/codemirror-theme-vscode';
21+
22+
<CodeMirror theme={vscodeDark} />
23+
24+
<CodeMirror
25+
theme={vscodeDarkInit({
26+
fontFamily: 'monospace',
27+
})}
28+
/>
29+
```
30+
1931
## Usage
2032

2133
```jsx

themes/vscode/src/index.ts

Lines changed: 84 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,90 @@
11
/**
2-
* @name github
2+
* https://github.com/uiwjs/react-codemirror/issues/409
33
*/
44
import { tags as t } from '@lezer/highlight';
5-
import { createTheme } from '@uiw/codemirror-themes';
5+
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes';
66

7-
export const vscodeDark = createTheme({
8-
theme: 'dark',
9-
settings: {
10-
background: '#1e1e1e',
11-
foreground: '#9cdcfe',
12-
caret: '#c6c6c6',
13-
selection: '#6199ff2f',
14-
selectionMatch: '#72a1ff59',
15-
lineHighlight: '#ffffff0f',
16-
gutterBackground: '#1e1e1e',
17-
gutterForeground: '#838383',
18-
gutterActiveForeground: '#fff',
19-
fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
20-
},
21-
styles: [
22-
{ tag: t.keyword, color: '#569cd6' },
23-
{
24-
tag: [t.controlKeyword, t.moduleKeyword],
25-
color: '#c586c0',
26-
},
27-
{
28-
tag: [t.name, t.deleted, t.character, t.macroName],
29-
color: '#9cdcfe',
30-
},
31-
{
32-
tag: [t.propertyName],
33-
color: '#9cdcfe',
7+
export function vscodeDarkInit(options?: CreateThemeOptions) {
8+
const { theme = 'dark', settings = {}, styles = [] } = options || {};
9+
return createTheme({
10+
theme: theme,
11+
settings: {
12+
background: '#1e1e1e',
13+
foreground: '#9cdcfe',
14+
caret: '#c6c6c6',
15+
selection: '#6199ff2f',
16+
selectionMatch: '#72a1ff59',
17+
lineHighlight: '#ffffff0f',
18+
gutterBackground: '#1e1e1e',
19+
gutterForeground: '#838383',
20+
gutterActiveForeground: '#fff',
21+
fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
22+
...settings,
3423
},
24+
styles: [
25+
{ tag: t.keyword, color: '#569cd6' },
26+
{
27+
tag: [t.controlKeyword, t.moduleKeyword],
28+
color: '#c586c0',
29+
},
30+
{
31+
tag: [t.name, t.deleted, t.character, t.macroName],
32+
color: '#9cdcfe',
33+
},
34+
{
35+
tag: [t.propertyName],
36+
color: '#9cdcfe',
37+
},
3538

36-
{ tag: [t.variableName, t.labelName], color: '#9cdcfe' },
37-
{
38-
tag: [t.color, t.constant(t.name), t.standard(t.name)],
39-
color: '#569cd6',
40-
},
41-
{ tag: [t.definition(t.name)], color: '#9cdcfe' },
42-
{
43-
tag: [t.typeName, t.className, t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace],
44-
color: '#4ec9b0',
45-
},
46-
{ tag: [t.tagName], color: '#569cd6' },
47-
{
48-
tag: [t.function(t.variableName), t.function(t.propertyName)],
49-
color: '#dcdcaa',
50-
},
51-
{ tag: [t.number], color: '#b5cea8' },
52-
{
53-
tag: [t.operator, t.operatorKeyword, t.url, t.escape, t.regexp, t.link, t.special(t.string)],
54-
color: '#d4d4d4',
55-
},
56-
{
57-
tag: [t.regexp],
58-
color: '#d16969',
59-
},
60-
{
61-
tag: [t.special(t.string)],
62-
color: '#ce9178',
63-
},
64-
{ tag: [t.meta, t.comment], color: '#6a9955' },
65-
{ tag: [t.punctuation, t.separator], color: '#d4d4d4' },
66-
{ tag: [t.angleBracket], color: '#808080' },
67-
{ tag: t.special(t.brace), color: '#569cd6' },
68-
{ tag: t.strong, fontWeight: 'bold' },
69-
{ tag: t.emphasis, fontStyle: 'italic' },
70-
{ tag: t.strikethrough, textDecoration: 'line-through' },
71-
{ tag: t.link, color: '#6a9955', textDecoration: 'underline' },
72-
{ tag: t.heading, fontWeight: 'bold', color: '#9cdcfe' },
73-
{
74-
tag: [t.atom, t.bool, t.special(t.variableName)],
75-
color: '#569cd6',
76-
},
77-
{
78-
tag: [t.processingInstruction, t.string, t.inserted],
79-
color: '#ce9178',
80-
},
81-
{ tag: t.invalid, color: '#ff0000' },
82-
],
83-
});
39+
{ tag: [t.variableName, t.labelName], color: '#9cdcfe' },
40+
{
41+
tag: [t.color, t.constant(t.name), t.standard(t.name)],
42+
color: '#569cd6',
43+
},
44+
{ tag: [t.definition(t.name)], color: '#9cdcfe' },
45+
{
46+
tag: [t.typeName, t.className, t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace],
47+
color: '#4ec9b0',
48+
},
49+
{ tag: [t.tagName], color: '#569cd6' },
50+
{
51+
tag: [t.function(t.variableName), t.function(t.propertyName)],
52+
color: '#dcdcaa',
53+
},
54+
{ tag: [t.number], color: '#b5cea8' },
55+
{
56+
tag: [t.operator, t.operatorKeyword, t.url, t.escape, t.regexp, t.link, t.special(t.string)],
57+
color: '#d4d4d4',
58+
},
59+
{
60+
tag: [t.regexp],
61+
color: '#d16969',
62+
},
63+
{
64+
tag: [t.special(t.string)],
65+
color: '#ce9178',
66+
},
67+
{ tag: [t.meta, t.comment], color: '#6a9955' },
68+
{ tag: [t.punctuation, t.separator], color: '#d4d4d4' },
69+
{ tag: [t.angleBracket], color: '#808080' },
70+
{ tag: t.special(t.brace), color: '#569cd6' },
71+
{ tag: t.strong, fontWeight: 'bold' },
72+
{ tag: t.emphasis, fontStyle: 'italic' },
73+
{ tag: t.strikethrough, textDecoration: 'line-through' },
74+
{ tag: t.link, color: '#6a9955', textDecoration: 'underline' },
75+
{ tag: t.heading, fontWeight: 'bold', color: '#9cdcfe' },
76+
{
77+
tag: [t.atom, t.bool, t.special(t.variableName)],
78+
color: '#569cd6',
79+
},
80+
{
81+
tag: [t.processingInstruction, t.string, t.inserted],
82+
color: '#ce9178',
83+
},
84+
{ tag: t.invalid, color: '#ff0000' },
85+
...styles,
86+
],
87+
});
88+
}
89+
90+
export const vscodeDark = vscodeDarkInit();

0 commit comments

Comments
 (0)