Skip to content

Commit

Permalink
feat(solarized): add package exports field.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Aug 25, 2023
1 parent 8bfc8a5 commit affc260
Show file tree
Hide file tree
Showing 7 changed files with 277 additions and 238 deletions.
3 changes: 3 additions & 0 deletions themes/solarized/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';

<CodeMirror theme={solarizedLight} />
<CodeMirror
Expand Down
6 changes: 6 additions & 0 deletions themes/solarized/dark.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module '@uiw/codemirror-theme-solarized/dark' {
import { CreateThemeOptions } from '@uiw/codemirror-themes';
export const defaultSettingsSolarizedDark: CreateThemeOptions['settings'];
export const solarizedDarkInit: (options?: Partial<CreateThemeOptions>) => import('@codemirror/state').Extension;
export const solarizedDark: import('@codemirror/state').Extension;
}
6 changes: 6 additions & 0 deletions themes/solarized/light.d.ts
Original file line number Diff line number Diff line change
@@ -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<CreateThemeOptions>) => import('@codemirror/state').Extension;
export const solarizedLight: import('@codemirror/state').Extension;
}
20 changes: 20 additions & 0 deletions themes/solarized/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -16,6 +34,8 @@
"url": "https://github.com/uiwjs/react-codemirror.git"
},
"files": [
"dark.d.ts",
"light.d.ts",
"src",
"esm",
"cjs"
Expand Down
120 changes: 120 additions & 0 deletions themes/solarized/src/dark.ts
Original file line number Diff line number Diff line change
@@ -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<CreateThemeOptions>) => {
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();
Loading

0 comments on commit affc260

Please sign in to comment.