Skip to content

Commit affc260

Browse files
committed
feat(solarized): add package exports field.
1 parent 8bfc8a5 commit affc260

File tree

7 files changed

+277
-238
lines changed

7 files changed

+277
-238
lines changed

themes/solarized/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ npm install @uiw/codemirror-theme-solarized --save
2424

2525
```jsx
2626
import { solarizedLight, solarizedLightInit, solarizedDark, solarizedDarkInit } from '@uiw/codemirror-theme-solarized';
27+
// Or
28+
import { solarizedDark, solarizedDarkInit } from '@uiw/codemirror-theme-solarized/dark';
29+
import { solarizedLight, solarizedLightInit } from '@uiw/codemirror-theme-solarized/light';
2730

2831
<CodeMirror theme={solarizedLight} />
2932
<CodeMirror

themes/solarized/dark.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module '@uiw/codemirror-theme-solarized/dark' {
2+
import { CreateThemeOptions } from '@uiw/codemirror-themes';
3+
export const defaultSettingsSolarizedDark: CreateThemeOptions['settings'];
4+
export const solarizedDarkInit: (options?: Partial<CreateThemeOptions>) => import('@codemirror/state').Extension;
5+
export const solarizedDark: import('@codemirror/state').Extension;
6+
}

themes/solarized/light.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module '@uiw/codemirror-theme-solarized/light' {
2+
import { CreateThemeOptions } from '@uiw/codemirror-themes';
3+
export const defaultSettingsSolarizedLight: CreateThemeOptions['settings'];
4+
export const solarizedLightInit: (options?: Partial<CreateThemeOptions>) => import('@codemirror/state').Extension;
5+
export const solarizedLight: import('@codemirror/state').Extension;
6+
}

themes/solarized/package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@
77
"license": "MIT",
88
"main": "./cjs/index.js",
99
"module": "./esm/index.js",
10+
"exports": {
11+
"./README.md": "./README.md",
12+
".": {
13+
"import": "./esm/index.js",
14+
"types": "./cjs/index.d.ts",
15+
"require": "./cjs/index.js"
16+
},
17+
"./light": {
18+
"import": "./esm/light.js",
19+
"types": "./cjs/light.d.ts",
20+
"require": "./cjs/light.js"
21+
},
22+
"./dark": {
23+
"import": "./esm/dark.js",
24+
"types": "./cjs/dark.d.ts",
25+
"require": "./cjs/dark.js"
26+
}
27+
},
1028
"scripts": {
1129
"watch": "tsbb watch src/*.ts --use-babel",
1230
"build": "tsbb build src/*.ts --use-babel"
@@ -16,6 +34,8 @@
1634
"url": "https://github.com/uiwjs/react-codemirror.git"
1735
},
1836
"files": [
37+
"dark.d.ts",
38+
"light.d.ts",
1939
"src",
2040
"esm",
2141
"cjs"

themes/solarized/src/dark.ts

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import { tags as t } from '@lezer/highlight';
2+
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes';
3+
4+
export const defaultSettingsSolarizedDark: CreateThemeOptions['settings'] = {
5+
background: '#002b36',
6+
foreground: '#93a1a1',
7+
caret: '#839496',
8+
selection: '#173541',
9+
selectionMatch: '#aafe661a',
10+
gutterBackground: '#00252f',
11+
gutterForeground: '#839496',
12+
lineHighlight: '#173541',
13+
};
14+
15+
export const solarizedDarkInit = (options?: Partial<CreateThemeOptions>) => {
16+
const { theme = 'dark', settings = {}, styles = [] } = options || {};
17+
return createTheme({
18+
theme: theme,
19+
settings: {
20+
...defaultSettingsSolarizedDark,
21+
...settings,
22+
},
23+
styles: [
24+
{ tag: t.keyword, color: '#859900' },
25+
{
26+
tag: [t.name, t.deleted, t.character, t.propertyName, t.macroName],
27+
color: '#2aa198',
28+
},
29+
{ tag: [t.variableName], color: '#93a1a1' },
30+
{ tag: [t.function(t.variableName)], color: '#268bd2' },
31+
{ tag: [t.labelName], color: '#d33682' },
32+
{
33+
tag: [t.color, t.constant(t.name), t.standard(t.name)],
34+
color: '#b58900',
35+
},
36+
{ tag: [t.definition(t.name), t.separator], color: '#2aa198' },
37+
{ tag: [t.brace], color: '#d33682' },
38+
{
39+
tag: [t.annotation],
40+
color: '#d30102',
41+
},
42+
{
43+
tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace],
44+
color: '#d33682',
45+
},
46+
{
47+
tag: [t.typeName, t.className],
48+
color: '#cb4b16',
49+
},
50+
{
51+
tag: [t.operator, t.operatorKeyword],
52+
color: '#6c71c4',
53+
},
54+
{
55+
tag: [t.tagName],
56+
color: '#268bd2',
57+
},
58+
{
59+
tag: [t.squareBracket],
60+
color: '#dc322f',
61+
},
62+
{
63+
tag: [t.angleBracket],
64+
color: '#586e75',
65+
},
66+
{
67+
tag: [t.attributeName],
68+
color: '#93a1a1',
69+
},
70+
{
71+
tag: [t.regexp],
72+
color: '#d30102',
73+
},
74+
{
75+
tag: [t.quote],
76+
color: '#859900',
77+
},
78+
{ tag: [t.string], color: '#b58900' },
79+
{
80+
tag: t.link,
81+
color: '#2aa198',
82+
textDecoration: 'underline',
83+
textUnderlinePosition: 'under',
84+
},
85+
{
86+
tag: [t.url, t.escape, t.special(t.string)],
87+
color: '#b58900',
88+
},
89+
{ tag: [t.meta], color: '#dc322f' },
90+
{ tag: [t.comment], color: '#586e75', fontStyle: 'italic' },
91+
{ tag: t.strong, fontWeight: 'bold', color: '#eee8d5' },
92+
{ tag: t.emphasis, fontStyle: 'italic', color: '#859900' },
93+
{ tag: t.strikethrough, textDecoration: 'line-through' },
94+
{ tag: t.heading, fontWeight: 'bold', color: '#b58900' },
95+
{ tag: t.heading1, fontWeight: 'bold', color: '#fdf6e3' },
96+
{
97+
tag: [t.heading2, t.heading3, t.heading4],
98+
fontWeight: 'bold',
99+
color: '#eee8d5',
100+
},
101+
{
102+
tag: [t.heading5, t.heading6],
103+
color: '#eee8d5',
104+
},
105+
{ tag: [t.atom, t.bool, t.special(t.variableName)], color: '#d33682' },
106+
{
107+
tag: [t.processingInstruction, t.inserted, t.contentSeparator],
108+
color: '#dc322f',
109+
},
110+
{
111+
tag: [t.contentSeparator],
112+
color: '#b58900',
113+
},
114+
{ tag: t.invalid, color: '#586e75', borderBottom: `1px dotted #dc322f` },
115+
...styles,
116+
],
117+
});
118+
};
119+
120+
export const solarizedDark = solarizedDarkInit();

0 commit comments

Comments
 (0)