|
| 1 | +import { tags as t } from '@lezer/highlight'; |
| 2 | +import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes'; |
| 3 | + |
| 4 | +export const defaultSettingsBasicDark: CreateThemeOptions['settings'] = { |
| 5 | + background: '#2E3235', |
| 6 | + foreground: '#DDDDDD', |
| 7 | + caret: '#DDDDDD', |
| 8 | + selection: '#202325', |
| 9 | + selectionMatch: '#B9D2FF30', |
| 10 | + gutterBackground: '#292d30', |
| 11 | + gutterForeground: '#808080', |
| 12 | + gutterBorder: '1px solid #ffffff10', |
| 13 | + lineHighlight: '#B9D2FF30', |
| 14 | +}; |
| 15 | + |
| 16 | +export const basicDarkInit = (options?: Partial<CreateThemeOptions>) => { |
| 17 | + const { theme = 'dark', settings = {}, styles = [] } = options || {}; |
| 18 | + return createTheme({ |
| 19 | + theme: theme, |
| 20 | + settings: { |
| 21 | + ...defaultSettingsBasicDark, |
| 22 | + ...settings, |
| 23 | + }, |
| 24 | + styles: [ |
| 25 | + { tag: t.keyword, color: '#fda331' }, |
| 26 | + { |
| 27 | + tag: [t.name, t.deleted, t.character, t.propertyName, t.macroName], |
| 28 | + color: '#b5bd68', |
| 29 | + }, |
| 30 | + { tag: [t.variableName], color: '#6fb3d2' }, |
| 31 | + { tag: [t.function(t.variableName)], color: '#fda331' }, |
| 32 | + { tag: [t.labelName], color: '#fc6d24' }, |
| 33 | + { |
| 34 | + tag: [t.color, t.constant(t.name), t.standard(t.name)], |
| 35 | + color: '#fda331', |
| 36 | + }, |
| 37 | + { tag: [t.definition(t.name), t.separator], color: '#cc99cc' }, |
| 38 | + { tag: [t.brace], color: '#cc99cc' }, |
| 39 | + { |
| 40 | + tag: [t.annotation], |
| 41 | + color: '#fc6d24', |
| 42 | + }, |
| 43 | + { |
| 44 | + tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace], |
| 45 | + color: '#fda331', |
| 46 | + }, |
| 47 | + { |
| 48 | + tag: [t.typeName, t.className], |
| 49 | + color: '#6fb3d2', |
| 50 | + }, |
| 51 | + { |
| 52 | + tag: [t.operator, t.operatorKeyword], |
| 53 | + color: '#cc99cc', |
| 54 | + }, |
| 55 | + { |
| 56 | + tag: [t.tagName], |
| 57 | + color: '#fda331', |
| 58 | + }, |
| 59 | + { |
| 60 | + tag: [t.squareBracket], |
| 61 | + color: '#cc99cc', |
| 62 | + }, |
| 63 | + { |
| 64 | + tag: [t.angleBracket], |
| 65 | + color: '#cc99cc', |
| 66 | + }, |
| 67 | + { |
| 68 | + tag: [t.attributeName], |
| 69 | + color: '#6fb3d2', |
| 70 | + }, |
| 71 | + { |
| 72 | + tag: [t.regexp], |
| 73 | + color: '#fda331', |
| 74 | + }, |
| 75 | + { |
| 76 | + tag: [t.quote], |
| 77 | + color: '#DDDDDD', |
| 78 | + }, |
| 79 | + { tag: [t.string], color: '#b5bd68' }, |
| 80 | + { |
| 81 | + tag: t.link, |
| 82 | + color: '#6987AF', |
| 83 | + textDecoration: 'underline', |
| 84 | + textUnderlinePosition: 'under', |
| 85 | + }, |
| 86 | + { |
| 87 | + tag: [t.url, t.escape, t.special(t.string)], |
| 88 | + color: '#8abeb7', |
| 89 | + }, |
| 90 | + { tag: [t.meta], color: '#A54543' }, |
| 91 | + { tag: [t.comment], color: '#808080', fontStyle: 'italic' }, |
| 92 | + { tag: t.monospace, color: '#DDDDDD' }, |
| 93 | + { tag: t.strong, fontWeight: 'bold', color: '#fda331' }, |
| 94 | + { tag: t.emphasis, fontStyle: 'italic', color: '#6fb3d2' }, |
| 95 | + { tag: t.strikethrough, textDecoration: 'line-through' }, |
| 96 | + { tag: t.heading, fontWeight: 'bold', color: '#DDDDDD' }, |
| 97 | + { tag: t.special(t.heading1), fontWeight: 'bold', color: '#DDDDDD' }, |
| 98 | + { tag: t.heading1, fontWeight: 'bold', color: '#DDDDDD' }, |
| 99 | + { |
| 100 | + tag: [t.heading2, t.heading3, t.heading4], |
| 101 | + fontWeight: 'bold', |
| 102 | + color: '#DDDDDD', |
| 103 | + }, |
| 104 | + { |
| 105 | + tag: [t.heading5, t.heading6], |
| 106 | + color: '#DDDDDD', |
| 107 | + }, |
| 108 | + { tag: [t.atom, t.bool, t.special(t.variableName)], color: '#8abeb7' }, |
| 109 | + { |
| 110 | + tag: [t.processingInstruction, t.inserted], |
| 111 | + color: '#8abeb7', |
| 112 | + }, |
| 113 | + { |
| 114 | + tag: [t.contentSeparator], |
| 115 | + color: '#6fb3d2', |
| 116 | + }, |
| 117 | + { tag: t.invalid, color: '#B9D2FF', borderBottom: `1px dotted ${'#fc6d24'}` }, |
| 118 | + ...styles, |
| 119 | + ], |
| 120 | + }); |
| 121 | +}; |
| 122 | + |
| 123 | +export const basicDark = basicDarkInit(); |
0 commit comments