Skip to content

Commit adf94e5

Browse files
committedDec 6, 2022
feat(okaidia): add okaidiaInit method to okaidia theme.
1 parent d45e5ee commit adf94e5

File tree

2 files changed

+76
-47
lines changed

2 files changed

+76
-47
lines changed
 

‎themes/okaidia/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,28 @@
1616
npm install @uiw/codemirror-theme-okaidia --save
1717
```
1818

19+
```jsx
20+
import { okaidia, okaidiaInit } from '@uiw/codemirror-theme-vscode';
21+
22+
<CodeMirror theme={okaidia} />
23+
<CodeMirror
24+
theme={okaidiaInit({
25+
settings: {
26+
caret: '#c6c6c6',
27+
fontFamily: 'monospace',
28+
}
29+
})}
30+
/>
31+
```
32+
33+
## API
34+
35+
```tsx
36+
import { CreateThemeOptions } from '@uiw/codemirror-themes';
37+
export declare const okaidiaInit: (options?: CreateThemeOptions) => import('@codemirror/state').Extension;
38+
export declare const okaidia: import('@codemirror/state').Extension;
39+
```
40+
1941
## Usage
2042

2143
```jsx

‎themes/okaidia/src/index.ts

+54-47
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,57 @@
11
import { tags as t } from '@lezer/highlight';
2-
import { createTheme } from '@uiw/codemirror-themes';
2+
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes';
33

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,
2318
},
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

Comments
 (0)
Please sign in to comment.