|
1 | 1 | import { tags as t } from '@lezer/highlight';
|
2 |
| -import { createTheme } from '@uiw/codemirror-themes'; |
| 2 | +import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes'; |
3 | 3 |
|
4 |
| -export const okaidia = createTheme({ |
5 |
| - theme: 'dark', |
6 |
| - settings: { |
7 |
| - background: '#272822', |
8 |
| - foreground: '#FFFFFF', |
9 |
| - caret: '#FFFFFF', |
10 |
| - selection: '#49483E', |
11 |
| - selectionMatch: '#49483E', |
12 |
| - gutterBackground: '#272822', |
13 |
| - gutterForeground: '#FFFFFF70', |
14 |
| - lineHighlight: '#00000059', |
15 |
| - }, |
16 |
| - styles: [ |
17 |
| - { tag: [t.comment, t.documentMeta], color: '#8292a2' }, |
18 |
| - { tag: [t.number, t.bool, t.null, t.atom], color: '#ae81ff' }, |
19 |
| - { tag: [t.attributeValue, t.className, t.name], color: '#e6db74' }, |
20 |
| - { |
21 |
| - tag: [t.propertyName, t.attributeName], |
22 |
| - color: '#a6e22e', |
| 4 | +export const okaidiaInit = (options?: CreateThemeOptions) => { |
| 5 | + const { theme = 'dark', settings = {}, styles = [] } = options || {}; |
| 6 | + return createTheme({ |
| 7 | + theme: theme, |
| 8 | + settings: { |
| 9 | + background: '#272822', |
| 10 | + foreground: '#FFFFFF', |
| 11 | + caret: '#FFFFFF', |
| 12 | + selection: '#49483E', |
| 13 | + selectionMatch: '#49483E', |
| 14 | + gutterBackground: '#272822', |
| 15 | + gutterForeground: '#FFFFFF70', |
| 16 | + lineHighlight: '#00000059', |
| 17 | + ...settings, |
23 | 18 | },
|
24 |
| - { |
25 |
| - tag: [t.variableName], |
26 |
| - color: '#9effff', |
27 |
| - }, |
28 |
| - { |
29 |
| - tag: [t.squareBracket], |
30 |
| - color: '#bababa', |
31 |
| - }, |
32 |
| - { |
33 |
| - tag: [t.string, t.special(t.brace)], |
34 |
| - color: '#e6db74', |
35 |
| - }, |
36 |
| - { |
37 |
| - tag: [t.regexp, t.className, t.typeName, t.definition(t.typeName)], |
38 |
| - color: '#66d9ef', |
39 |
| - }, |
40 |
| - { |
41 |
| - tag: [t.definition(t.variableName), t.definition(t.propertyName), t.function(t.variableName)], |
42 |
| - color: '#fd971f', |
43 |
| - }, |
44 |
| - // { tag: t.keyword, color: '#f92672' }, |
45 |
| - { |
46 |
| - tag: [t.keyword, t.definitionKeyword, t.modifier, t.tagName, t.angleBracket], |
47 |
| - color: '#f92672', |
48 |
| - }, |
49 |
| - ], |
50 |
| -}); |
| 19 | + styles: [ |
| 20 | + { tag: [t.comment, t.documentMeta], color: '#8292a2' }, |
| 21 | + { tag: [t.number, t.bool, t.null, t.atom], color: '#ae81ff' }, |
| 22 | + { tag: [t.attributeValue, t.className, t.name], color: '#e6db74' }, |
| 23 | + { |
| 24 | + tag: [t.propertyName, t.attributeName], |
| 25 | + color: '#a6e22e', |
| 26 | + }, |
| 27 | + { |
| 28 | + tag: [t.variableName], |
| 29 | + color: '#9effff', |
| 30 | + }, |
| 31 | + { |
| 32 | + tag: [t.squareBracket], |
| 33 | + color: '#bababa', |
| 34 | + }, |
| 35 | + { |
| 36 | + tag: [t.string, t.special(t.brace)], |
| 37 | + color: '#e6db74', |
| 38 | + }, |
| 39 | + { |
| 40 | + tag: [t.regexp, t.className, t.typeName, t.definition(t.typeName)], |
| 41 | + color: '#66d9ef', |
| 42 | + }, |
| 43 | + { |
| 44 | + tag: [t.definition(t.variableName), t.definition(t.propertyName), t.function(t.variableName)], |
| 45 | + color: '#fd971f', |
| 46 | + }, |
| 47 | + // { tag: t.keyword, color: '#f92672' }, |
| 48 | + { |
| 49 | + tag: [t.keyword, t.definitionKeyword, t.modifier, t.tagName, t.angleBracket], |
| 50 | + color: '#f92672', |
| 51 | + }, |
| 52 | + ...styles, |
| 53 | + ], |
| 54 | + }); |
| 55 | +}; |
| 56 | + |
| 57 | +export const okaidia = okaidiaInit(); |
0 commit comments