Skip to content

Commit b8cf12f

Browse files
committed
feat(abcdef): add abcdefInit method to abcdef theme.
1 parent 61f38d1 commit b8cf12f

File tree

2 files changed

+66
-33
lines changed

2 files changed

+66
-33
lines changed

themes/abcdef/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@
1616
npm install @uiw/codemirror-theme-abcdef --save
1717
```
1818

19+
```jsx
20+
import { tags as t } from '@lezer/highlight';
21+
import { abcdef, abcdefInit } from '@uiw/codemirror-theme-abcdef';
22+
23+
<CodeMirror theme={abcdef} />
24+
<CodeMirror
25+
theme={abcdefInit({
26+
settings: {
27+
caret: '#c6c6c6',
28+
fontFamily: 'monospace',
29+
},
30+
styles: [
31+
{ tag: t.comment, color: '#6272a4' },
32+
]
33+
})}
34+
/>
35+
```
36+
37+
## API
38+
39+
```tsx
40+
import { CreateThemeOptions } from '@uiw/codemirror-themes';
41+
export declare const abcdefInit: (options?: CreateThemeOptions) => import('@codemirror/state').Extension;
42+
export declare const abcdef: import('@codemirror/state').Extension;
43+
```
44+
1945
## Usage
2046

2147
```jsx

themes/abcdef/src/index.ts

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,44 @@
44
* https://codemirror.net/5/theme/abcdef.css
55
*/
66
import { tags as t } from '@lezer/highlight';
7-
import { createTheme } from '@uiw/codemirror-themes';
7+
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes';
88

9-
export const abcdef = createTheme({
10-
theme: 'dark',
11-
settings: {
12-
background: '#0f0f0f',
13-
foreground: '#defdef',
14-
caret: '#00FF00',
15-
selection: '#515151',
16-
selectionMatch: '#515151',
17-
gutterBackground: '#555',
18-
gutterForeground: '#FFFFFF',
19-
lineHighlight: '#314151',
20-
},
21-
styles: [
22-
{ tag: t.keyword, color: 'darkgoldenrod', fontWeight: 'bold' },
23-
{ tag: t.atom, color: '#77F' },
24-
{ tag: t.comment, color: '#7a7b7c', fontStyle: 'italic' },
25-
{ tag: t.number, color: 'violet' },
26-
{ tag: t.definition(t.variableName), color: '#fffabc' },
27-
{ tag: t.variableName, color: '#abcdef' },
28-
{ tag: t.function(t.variableName), color: '#fffabc' },
29-
{ tag: t.typeName, color: '#FFDD44' },
30-
{ tag: t.tagName, color: '#def' },
31-
{ tag: t.string, color: '#2b4' },
32-
{ tag: t.meta, color: '#C9F' },
33-
// { tag: t.qualifier, color: '#FFF700' },
34-
// { tag: t.builtin, color: '#30aabc' },
35-
{ tag: t.bracket, color: '#8a8a8a' },
36-
{ tag: t.attributeName, color: '#DDFF00' },
37-
{ tag: t.heading, color: 'aquamarine', fontWeight: 'bold' },
38-
{ tag: t.link, color: 'blueviolet', fontWeight: 'bold' },
39-
],
40-
});
9+
export const abcdefInit = (options?: CreateThemeOptions) => {
10+
const { theme = 'dark', settings = {}, styles = [] } = options || {};
11+
return createTheme({
12+
theme: theme,
13+
settings: {
14+
background: '#0f0f0f',
15+
foreground: '#defdef',
16+
caret: '#00FF00',
17+
selection: '#515151',
18+
selectionMatch: '#515151',
19+
gutterBackground: '#555',
20+
gutterForeground: '#FFFFFF',
21+
lineHighlight: '#314151',
22+
...settings,
23+
},
24+
styles: [
25+
{ tag: t.keyword, color: 'darkgoldenrod', fontWeight: 'bold' },
26+
{ tag: t.atom, color: '#77F' },
27+
{ tag: t.comment, color: '#7a7b7c', fontStyle: 'italic' },
28+
{ tag: t.number, color: 'violet' },
29+
{ tag: t.definition(t.variableName), color: '#fffabc' },
30+
{ tag: t.variableName, color: '#abcdef' },
31+
{ tag: t.function(t.variableName), color: '#fffabc' },
32+
{ tag: t.typeName, color: '#FFDD44' },
33+
{ tag: t.tagName, color: '#def' },
34+
{ tag: t.string, color: '#2b4' },
35+
{ tag: t.meta, color: '#C9F' },
36+
// { tag: t.qualifier, color: '#FFF700' },
37+
// { tag: t.builtin, color: '#30aabc' },
38+
{ tag: t.bracket, color: '#8a8a8a' },
39+
{ tag: t.attributeName, color: '#DDFF00' },
40+
{ tag: t.heading, color: 'aquamarine', fontWeight: 'bold' },
41+
{ tag: t.link, color: 'blueviolet', fontWeight: 'bold' },
42+
...styles,
43+
],
44+
});
45+
};
46+
47+
export const abcdef = abcdefInit();

0 commit comments

Comments
 (0)