Skip to content

Commit 4044b17

Browse files
committedDec 7, 2022
feat(duotone): add duotoneLightInit/duotoneDarkInit method to duotone theme.
1 parent 3cd796d commit 4044b17

File tree

3 files changed

+84
-46
lines changed

3 files changed

+84
-46
lines changed
 

‎themes/duotone/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,30 @@
2020
npm install @uiw/codemirror-theme-duotone --save
2121
```
2222

23+
```jsx
24+
import { duotoneLight, duotoneLightInit, duotoneDark, duotoneDarkInit } from '@uiw/codemirror-theme-duotone';
25+
26+
<CodeMirror theme={duotoneLight} />
27+
<CodeMirror
28+
theme={duotoneLightInit({
29+
settings: {
30+
caret: '#c6c6c6',
31+
fontFamily: 'monospace',
32+
}
33+
})}
34+
/>
35+
```
36+
37+
## API
38+
39+
```tsx
40+
import { CreateThemeOptions } from '@uiw/codemirror-themes';
41+
export declare const duotoneLightInit: (options?: CreateThemeOptions) => import('@codemirror/state').Extension;
42+
export declare const duotoneLight: import('@codemirror/state').Extension;
43+
export declare const duotoneDarkInit: (options?: CreateThemeOptions) => import('@codemirror/state').Extension;
44+
export declare const duotoneDark: import('@codemirror/state').Extension;
45+
```
46+
2347
## Usage
2448

2549
```jsx

‎themes/duotone/src/index.ts

+59-45
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,64 @@
44
* by Bram de Haan, adapted from DuoTone themes by Simurai (http://simurai.com/projects/2016/01/01/duotone-themes)
55
*/
66
import { tags as t } from '@lezer/highlight';
7-
import { createTheme } from '@uiw/codemirror-themes';
7+
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes';
88

9-
export const duotoneLight = createTheme({
10-
theme: 'light',
11-
settings: {
12-
background: '#faf8f5',
13-
foreground: '#b29762',
14-
caret: '#93abdc',
15-
selection: '#e3dcce',
16-
selectionMatch: '#e3dcce',
17-
gutterBackground: '#faf8f5',
18-
gutterForeground: '#cdc4b1',
19-
lineHighlight: '#EFEFEF',
20-
},
21-
styles: [
22-
{ tag: [t.comment, t.bracket], color: '#b6ad9a' },
23-
{ tag: [t.atom, t.number, t.keyword, t.link, t.attributeName, t.quote], color: '#063289' },
24-
{ tag: [t.emphasis, t.heading, t.tagName, t.propertyName, t.variableName], color: '#2d2006' },
25-
{ tag: [t.typeName, t.url, t.string], color: '#896724' },
26-
{ tag: [t.operator, t.string], color: '#1659df' },
27-
{ tag: [t.propertyName], color: '#b29762' },
28-
{ tag: [t.unit, t.punctuation], color: '#063289' },
29-
],
30-
});
9+
export const duotoneLightInit = (options?: CreateThemeOptions) => {
10+
const { theme = 'light', settings = {}, styles = [] } = options || {};
11+
return createTheme({
12+
theme: theme,
13+
settings: {
14+
background: '#faf8f5',
15+
foreground: '#b29762',
16+
caret: '#93abdc',
17+
selection: '#e3dcce',
18+
selectionMatch: '#e3dcce',
19+
gutterBackground: '#faf8f5',
20+
gutterForeground: '#cdc4b1',
21+
lineHighlight: '#EFEFEF',
22+
...settings,
23+
},
24+
styles: [
25+
{ tag: [t.comment, t.bracket], color: '#b6ad9a' },
26+
{ tag: [t.atom, t.number, t.keyword, t.link, t.attributeName, t.quote], color: '#063289' },
27+
{ tag: [t.emphasis, t.heading, t.tagName, t.propertyName, t.variableName], color: '#2d2006' },
28+
{ tag: [t.typeName, t.url, t.string], color: '#896724' },
29+
{ tag: [t.operator, t.string], color: '#1659df' },
30+
{ tag: [t.propertyName], color: '#b29762' },
31+
{ tag: [t.unit, t.punctuation], color: '#063289' },
32+
...styles,
33+
],
34+
});
35+
};
3136

32-
export const duotoneDark = createTheme({
33-
theme: 'dark',
34-
settings: {
35-
background: '#2a2734',
36-
foreground: '#6c6783',
37-
caret: '#ffad5c',
38-
selection: 'rgba(255, 255, 255, 0.1)',
39-
gutterBackground: '#2a2734',
40-
gutterForeground: '#545167',
41-
lineHighlight: '#36334280',
42-
},
43-
styles: [
44-
{ tag: [t.comment, t.bracket], color: '#6c6783' },
45-
{ tag: [t.atom, t.number, t.keyword, t.link, t.attributeName, t.quote], color: '#ffcc99' },
46-
{ tag: [t.emphasis, t.heading, t.tagName, t.propertyName, t.className, t.variableName], color: '#eeebff' },
47-
{ tag: [t.typeName, t.url], color: '#7a63ee' },
48-
{ tag: t.operator, color: '#ffad5c' },
49-
{ tag: t.string, color: '#ffb870' },
50-
{ tag: [t.propertyName], color: '#9a86fd' },
51-
{ tag: [t.unit, t.punctuation], color: '#e09142' },
52-
],
53-
});
37+
export const duotoneLight = duotoneLightInit();
38+
39+
export const duotoneDarkInit = (options?: CreateThemeOptions) => {
40+
const { theme = 'light', settings = {}, styles = [] } = options || {};
41+
return createTheme({
42+
theme: theme,
43+
settings: {
44+
background: '#2a2734',
45+
foreground: '#6c6783',
46+
caret: '#ffad5c',
47+
selection: 'rgba(255, 255, 255, 0.1)',
48+
gutterBackground: '#2a2734',
49+
gutterForeground: '#545167',
50+
lineHighlight: '#36334280',
51+
...settings,
52+
},
53+
styles: [
54+
{ tag: [t.comment, t.bracket], color: '#6c6783' },
55+
{ tag: [t.atom, t.number, t.keyword, t.link, t.attributeName, t.quote], color: '#ffcc99' },
56+
{ tag: [t.emphasis, t.heading, t.tagName, t.propertyName, t.className, t.variableName], color: '#eeebff' },
57+
{ tag: [t.typeName, t.url], color: '#7a63ee' },
58+
{ tag: t.operator, color: '#ffad5c' },
59+
{ tag: t.string, color: '#ffb870' },
60+
{ tag: [t.propertyName], color: '#9a86fd' },
61+
{ tag: [t.unit, t.punctuation], color: '#e09142' },
62+
...styles,
63+
],
64+
});
65+
};
66+
67+
export const duotoneDark = duotoneDarkInit();

‎themes/eclipse/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ npm install @uiw/codemirror-theme-eclipse --save
1717
```
1818

1919
```jsx
20-
import { eclipse, eclipseInit } from '@uiw/codemirror-theme-github';
20+
import { eclipse, eclipseInit } from '@uiw/codemirror-theme-eclipse';
2121

2222
<CodeMirror theme={eclipse} />
2323
<CodeMirror

0 commit comments

Comments
 (0)
Please sign in to comment.