diff --git a/themes/solarized/README.md b/themes/solarized/README.md index 35971029c..482bc70d6 100644 --- a/themes/solarized/README.md +++ b/themes/solarized/README.md @@ -24,6 +24,9 @@ npm install @uiw/codemirror-theme-solarized --save ```jsx import { solarizedLight, solarizedLightInit, solarizedDark, solarizedDarkInit } from '@uiw/codemirror-theme-solarized'; +// Or +import { solarizedDark, solarizedDarkInit } from '@uiw/codemirror-theme-solarized/dark'; +import { solarizedLight, solarizedLightInit } from '@uiw/codemirror-theme-solarized/light'; ) => import('@codemirror/state').Extension; + export const solarizedDark: import('@codemirror/state').Extension; +} diff --git a/themes/solarized/light.d.ts b/themes/solarized/light.d.ts new file mode 100644 index 000000000..ef006c3f6 --- /dev/null +++ b/themes/solarized/light.d.ts @@ -0,0 +1,6 @@ +declare module '@uiw/codemirror-theme-solarized/light' { + import { CreateThemeOptions } from '@uiw/codemirror-themes'; + export const defaultSettingsSolarizedLight: CreateThemeOptions['settings']; + export const solarizedLightInit: (options?: Partial) => import('@codemirror/state').Extension; + export const solarizedLight: import('@codemirror/state').Extension; +} diff --git a/themes/solarized/package.json b/themes/solarized/package.json index 921fcf0ce..ff78142c7 100644 --- a/themes/solarized/package.json +++ b/themes/solarized/package.json @@ -7,6 +7,24 @@ "license": "MIT", "main": "./cjs/index.js", "module": "./esm/index.js", + "exports": { + "./README.md": "./README.md", + ".": { + "import": "./esm/index.js", + "types": "./cjs/index.d.ts", + "require": "./cjs/index.js" + }, + "./light": { + "import": "./esm/light.js", + "types": "./cjs/light.d.ts", + "require": "./cjs/light.js" + }, + "./dark": { + "import": "./esm/dark.js", + "types": "./cjs/dark.d.ts", + "require": "./cjs/dark.js" + } + }, "scripts": { "watch": "tsbb watch src/*.ts --use-babel", "build": "tsbb build src/*.ts --use-babel" @@ -16,6 +34,8 @@ "url": "https://github.com/uiwjs/react-codemirror.git" }, "files": [ + "dark.d.ts", + "light.d.ts", "src", "esm", "cjs" diff --git a/themes/solarized/src/dark.ts b/themes/solarized/src/dark.ts new file mode 100644 index 000000000..e31173646 --- /dev/null +++ b/themes/solarized/src/dark.ts @@ -0,0 +1,120 @@ +import { tags as t } from '@lezer/highlight'; +import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes'; + +export const defaultSettingsSolarizedDark: CreateThemeOptions['settings'] = { + background: '#002b36', + foreground: '#93a1a1', + caret: '#839496', + selection: '#173541', + selectionMatch: '#aafe661a', + gutterBackground: '#00252f', + gutterForeground: '#839496', + lineHighlight: '#173541', +}; + +export const solarizedDarkInit = (options?: Partial) => { + const { theme = 'dark', settings = {}, styles = [] } = options || {}; + return createTheme({ + theme: theme, + settings: { + ...defaultSettingsSolarizedDark, + ...settings, + }, + styles: [ + { tag: t.keyword, color: '#859900' }, + { + tag: [t.name, t.deleted, t.character, t.propertyName, t.macroName], + color: '#2aa198', + }, + { tag: [t.variableName], color: '#93a1a1' }, + { tag: [t.function(t.variableName)], color: '#268bd2' }, + { tag: [t.labelName], color: '#d33682' }, + { + tag: [t.color, t.constant(t.name), t.standard(t.name)], + color: '#b58900', + }, + { tag: [t.definition(t.name), t.separator], color: '#2aa198' }, + { tag: [t.brace], color: '#d33682' }, + { + tag: [t.annotation], + color: '#d30102', + }, + { + tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace], + color: '#d33682', + }, + { + tag: [t.typeName, t.className], + color: '#cb4b16', + }, + { + tag: [t.operator, t.operatorKeyword], + color: '#6c71c4', + }, + { + tag: [t.tagName], + color: '#268bd2', + }, + { + tag: [t.squareBracket], + color: '#dc322f', + }, + { + tag: [t.angleBracket], + color: '#586e75', + }, + { + tag: [t.attributeName], + color: '#93a1a1', + }, + { + tag: [t.regexp], + color: '#d30102', + }, + { + tag: [t.quote], + color: '#859900', + }, + { tag: [t.string], color: '#b58900' }, + { + tag: t.link, + color: '#2aa198', + textDecoration: 'underline', + textUnderlinePosition: 'under', + }, + { + tag: [t.url, t.escape, t.special(t.string)], + color: '#b58900', + }, + { tag: [t.meta], color: '#dc322f' }, + { tag: [t.comment], color: '#586e75', fontStyle: 'italic' }, + { tag: t.strong, fontWeight: 'bold', color: '#eee8d5' }, + { tag: t.emphasis, fontStyle: 'italic', color: '#859900' }, + { tag: t.strikethrough, textDecoration: 'line-through' }, + { tag: t.heading, fontWeight: 'bold', color: '#b58900' }, + { tag: t.heading1, fontWeight: 'bold', color: '#fdf6e3' }, + { + tag: [t.heading2, t.heading3, t.heading4], + fontWeight: 'bold', + color: '#eee8d5', + }, + { + tag: [t.heading5, t.heading6], + color: '#eee8d5', + }, + { tag: [t.atom, t.bool, t.special(t.variableName)], color: '#d33682' }, + { + tag: [t.processingInstruction, t.inserted, t.contentSeparator], + color: '#dc322f', + }, + { + tag: [t.contentSeparator], + color: '#b58900', + }, + { tag: t.invalid, color: '#586e75', borderBottom: `1px dotted #dc322f` }, + ...styles, + ], + }); +}; + +export const solarizedDark = solarizedDarkInit(); diff --git a/themes/solarized/src/index.ts b/themes/solarized/src/index.ts index e5d1ac8e6..4100599d4 100644 --- a/themes/solarized/src/index.ts +++ b/themes/solarized/src/index.ts @@ -1,238 +1,2 @@ -import { tags as t } from '@lezer/highlight'; -import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes'; - -export const defaultSettingsSolarizedLight: CreateThemeOptions['settings'] = { - background: '#fdf6e3', - foreground: '#657b83', - caret: '#586e75', - selection: '#dfd9c8', - selectionMatch: '#dfd9c8', - gutterBackground: '#00000010', - gutterForeground: '#657b83', - lineHighlight: '#dfd9c8', -}; - -export const solarizedLightInit = (options?: Partial) => { - const { theme = 'light', settings = {}, styles = [] } = options || {}; - return createTheme({ - theme: theme, - settings: { - ...defaultSettingsSolarizedLight, - ...settings, - }, - styles: [ - { tag: t.keyword, color: '#859900' }, - { - tag: [t.name, t.deleted, t.character, t.propertyName, t.macroName], - color: '#2aa198', - }, - { tag: [t.variableName], color: '#268bd2' }, - { tag: [t.function(t.variableName)], color: '#268bd2' }, - { tag: [t.labelName], color: '#d33682' }, - { - tag: [t.color, t.constant(t.name), t.standard(t.name)], - color: '#b58900', - }, - { tag: [t.definition(t.name), t.separator], color: '#2aa198' }, - { tag: [t.brace], color: '#d33682' }, - { - tag: [t.annotation], - color: '#d30102', - }, - { - tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace], - color: '#d33682', - }, - { - tag: [t.typeName, t.className], - color: '#cb4b16', - }, - { - tag: [t.operator, t.operatorKeyword], - color: '#6c71c4', - }, - { - tag: [t.tagName], - color: '#268bd2', - }, - { - tag: [t.squareBracket], - color: '#dc322f', - }, - { - tag: [t.angleBracket], - color: '#073642', - }, - { - tag: [t.attributeName], - color: '#93a1a1', - }, - { - tag: [t.regexp], - color: '#d30102', - }, - { - tag: [t.quote], - color: '#859900', - }, - { tag: [t.string], color: '#b58900' }, - { - tag: t.link, - color: '#2aa198', - textDecoration: 'underline', - textUnderlinePosition: 'under', - }, - { - tag: [t.url, t.escape, t.special(t.string)], - color: '#b58900', - }, - { tag: [t.meta], color: '#dc322f' }, - { tag: [t.comment], color: '#586e75', fontStyle: 'italic' }, - { tag: t.strong, fontWeight: 'bold', color: '#586e75' }, - { tag: t.emphasis, fontStyle: 'italic', color: '#859900' }, - { tag: t.strikethrough, textDecoration: 'line-through' }, - { tag: t.heading, fontWeight: 'bold', color: '#b58900' }, - { tag: t.heading1, fontWeight: 'bold', color: '#002b36' }, - { - tag: [t.heading2, t.heading3, t.heading4], - fontWeight: 'bold', - color: '#002b36', - }, - { - tag: [t.heading5, t.heading6], - color: '#002b36', - }, - { tag: [t.atom, t.bool, t.special(t.variableName)], color: '#d33682' }, - { - tag: [t.processingInstruction, t.inserted, t.contentSeparator], - color: '#dc322f', - }, - { - tag: [t.contentSeparator], - color: '#b58900', - }, - { tag: t.invalid, color: '#073642', borderBottom: `1px dotted #dc322f` }, - ...styles, - ], - }); -}; - -export const solarizedLight = solarizedLightInit(); - -export const defaultSettingsSolarizedDark: CreateThemeOptions['settings'] = { - background: '#002b36', - foreground: '#93a1a1', - caret: '#839496', - selection: '#173541', - selectionMatch: '#aafe661a', - gutterBackground: '#00252f', - gutterForeground: '#839496', - lineHighlight: '#173541', -}; - -export const solarizedDarkInit = (options?: Partial) => { - const { theme = 'dark', settings = {}, styles = [] } = options || {}; - return createTheme({ - theme: theme, - settings: { - ...defaultSettingsSolarizedDark, - ...settings, - }, - styles: [ - { tag: t.keyword, color: '#859900' }, - { - tag: [t.name, t.deleted, t.character, t.propertyName, t.macroName], - color: '#2aa198', - }, - { tag: [t.variableName], color: '#93a1a1' }, - { tag: [t.function(t.variableName)], color: '#268bd2' }, - { tag: [t.labelName], color: '#d33682' }, - { - tag: [t.color, t.constant(t.name), t.standard(t.name)], - color: '#b58900', - }, - { tag: [t.definition(t.name), t.separator], color: '#2aa198' }, - { tag: [t.brace], color: '#d33682' }, - { - tag: [t.annotation], - color: '#d30102', - }, - { - tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace], - color: '#d33682', - }, - { - tag: [t.typeName, t.className], - color: '#cb4b16', - }, - { - tag: [t.operator, t.operatorKeyword], - color: '#6c71c4', - }, - { - tag: [t.tagName], - color: '#268bd2', - }, - { - tag: [t.squareBracket], - color: '#dc322f', - }, - { - tag: [t.angleBracket], - color: '#586e75', - }, - { - tag: [t.attributeName], - color: '#93a1a1', - }, - { - tag: [t.regexp], - color: '#d30102', - }, - { - tag: [t.quote], - color: '#859900', - }, - { tag: [t.string], color: '#b58900' }, - { - tag: t.link, - color: '#2aa198', - textDecoration: 'underline', - textUnderlinePosition: 'under', - }, - { - tag: [t.url, t.escape, t.special(t.string)], - color: '#b58900', - }, - { tag: [t.meta], color: '#dc322f' }, - { tag: [t.comment], color: '#586e75', fontStyle: 'italic' }, - { tag: t.strong, fontWeight: 'bold', color: '#eee8d5' }, - { tag: t.emphasis, fontStyle: 'italic', color: '#859900' }, - { tag: t.strikethrough, textDecoration: 'line-through' }, - { tag: t.heading, fontWeight: 'bold', color: '#b58900' }, - { tag: t.heading1, fontWeight: 'bold', color: '#fdf6e3' }, - { - tag: [t.heading2, t.heading3, t.heading4], - fontWeight: 'bold', - color: '#eee8d5', - }, - { - tag: [t.heading5, t.heading6], - color: '#eee8d5', - }, - { tag: [t.atom, t.bool, t.special(t.variableName)], color: '#d33682' }, - { - tag: [t.processingInstruction, t.inserted, t.contentSeparator], - color: '#dc322f', - }, - { - tag: [t.contentSeparator], - color: '#b58900', - }, - { tag: t.invalid, color: '#586e75', borderBottom: `1px dotted #dc322f` }, - ...styles, - ], - }); -}; - -export const solarizedDark = solarizedDarkInit(); +export * from './dark'; +export * from './light'; diff --git a/themes/solarized/src/light.ts b/themes/solarized/src/light.ts new file mode 100644 index 000000000..66d00f232 --- /dev/null +++ b/themes/solarized/src/light.ts @@ -0,0 +1,120 @@ +import { tags as t } from '@lezer/highlight'; +import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes'; + +export const defaultSettingsSolarizedLight: CreateThemeOptions['settings'] = { + background: '#fdf6e3', + foreground: '#657b83', + caret: '#586e75', + selection: '#dfd9c8', + selectionMatch: '#dfd9c8', + gutterBackground: '#00000010', + gutterForeground: '#657b83', + lineHighlight: '#dfd9c8', +}; + +export const solarizedLightInit = (options?: Partial) => { + const { theme = 'light', settings = {}, styles = [] } = options || {}; + return createTheme({ + theme: theme, + settings: { + ...defaultSettingsSolarizedLight, + ...settings, + }, + styles: [ + { tag: t.keyword, color: '#859900' }, + { + tag: [t.name, t.deleted, t.character, t.propertyName, t.macroName], + color: '#2aa198', + }, + { tag: [t.variableName], color: '#268bd2' }, + { tag: [t.function(t.variableName)], color: '#268bd2' }, + { tag: [t.labelName], color: '#d33682' }, + { + tag: [t.color, t.constant(t.name), t.standard(t.name)], + color: '#b58900', + }, + { tag: [t.definition(t.name), t.separator], color: '#2aa198' }, + { tag: [t.brace], color: '#d33682' }, + { + tag: [t.annotation], + color: '#d30102', + }, + { + tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace], + color: '#d33682', + }, + { + tag: [t.typeName, t.className], + color: '#cb4b16', + }, + { + tag: [t.operator, t.operatorKeyword], + color: '#6c71c4', + }, + { + tag: [t.tagName], + color: '#268bd2', + }, + { + tag: [t.squareBracket], + color: '#dc322f', + }, + { + tag: [t.angleBracket], + color: '#073642', + }, + { + tag: [t.attributeName], + color: '#93a1a1', + }, + { + tag: [t.regexp], + color: '#d30102', + }, + { + tag: [t.quote], + color: '#859900', + }, + { tag: [t.string], color: '#b58900' }, + { + tag: t.link, + color: '#2aa198', + textDecoration: 'underline', + textUnderlinePosition: 'under', + }, + { + tag: [t.url, t.escape, t.special(t.string)], + color: '#b58900', + }, + { tag: [t.meta], color: '#dc322f' }, + { tag: [t.comment], color: '#586e75', fontStyle: 'italic' }, + { tag: t.strong, fontWeight: 'bold', color: '#586e75' }, + { tag: t.emphasis, fontStyle: 'italic', color: '#859900' }, + { tag: t.strikethrough, textDecoration: 'line-through' }, + { tag: t.heading, fontWeight: 'bold', color: '#b58900' }, + { tag: t.heading1, fontWeight: 'bold', color: '#002b36' }, + { + tag: [t.heading2, t.heading3, t.heading4], + fontWeight: 'bold', + color: '#002b36', + }, + { + tag: [t.heading5, t.heading6], + color: '#002b36', + }, + { tag: [t.atom, t.bool, t.special(t.variableName)], color: '#d33682' }, + { + tag: [t.processingInstruction, t.inserted, t.contentSeparator], + color: '#dc322f', + }, + { + tag: [t.contentSeparator], + color: '#b58900', + }, + { tag: t.invalid, color: '#073642', borderBottom: `1px dotted #dc322f` }, + ...styles, + ], + }); +}; + +export const solarizedLight = solarizedLightInit();