|
4 | 4 | * by Bram de Haan, adapted from DuoTone themes by Simurai (http://simurai.com/projects/2016/01/01/duotone-themes)
|
5 | 5 | */
|
6 | 6 | import { tags as t } from '@lezer/highlight';
|
7 |
| -import { createTheme } from '@uiw/codemirror-themes'; |
| 7 | +import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes'; |
8 | 8 |
|
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 | +}; |
31 | 36 |
|
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(); |
0 commit comments