Skip to content

Commit 0515402

Browse files
committedDec 7, 2022
feat(bespin): add bespinInit method to bespin theme.
1 parent 23c896c commit 0515402

File tree

2 files changed

+58
-25
lines changed

2 files changed

+58
-25
lines changed
 

‎themes/bespin/README.md

+26
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@
1616
npm install @uiw/codemirror-theme-bespin --save
1717
```
1818

19+
```jsx
20+
import { tags as t } from '@lezer/highlight';
21+
import { bespin, bespinInit } from '@uiw/codemirror-theme-bespin';
22+
23+
<CodeMirror theme={bespin} />
24+
<CodeMirror
25+
theme={bespinInit({
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 bespinInit: (options?: CreateThemeOptions) => import('@codemirror/state').Extension;
42+
export declare const bespin: import('@codemirror/state').Extension;
43+
```
44+
1945
## Usage
2046

2147
```jsx

‎themes/bespin/src/index.ts

+32-25
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,36 @@
66
* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
77
*/
88
import { tags as t } from '@lezer/highlight';
9-
import { createTheme } from '@uiw/codemirror-themes';
9+
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes';
1010

11-
export const bespin = createTheme({
12-
theme: 'dark',
13-
settings: {
14-
background: '#28211c',
15-
foreground: '#9d9b97',
16-
caret: '#797977',
17-
selection: '#36312e',
18-
selectionMatch: '#4f382b',
19-
gutterBackground: '#28211c',
20-
gutterForeground: '#666666',
21-
lineHighlight: 'rgba(255, 255, 255, 0.1)',
22-
},
23-
styles: [
24-
{ tag: [t.atom, t.number, t.link, t.bool], color: '#9b859d' },
25-
{ tag: t.comment, color: '#937121' },
26-
{ tag: [t.keyword, t.tagName], color: '#cf6a4c' },
27-
{ tag: t.string, color: '#f9ee98' },
28-
{ tag: t.bracket, color: '#9d9b97' },
29-
{ tag: [t.variableName], color: '#5ea6ea' },
30-
{ tag: t.definition(t.variableName), color: '#cf7d34' },
31-
{ tag: [t.function(t.variableName), t.className], color: '#cf7d34' },
32-
{ tag: [t.propertyName, t.attributeName], color: '#54be0d' },
33-
],
34-
});
11+
export const bespinInit = (options?: CreateThemeOptions) => {
12+
const { theme = 'dark', settings = {}, styles = [] } = options || {};
13+
return createTheme({
14+
theme: theme,
15+
settings: {
16+
background: '#28211c',
17+
foreground: '#9d9b97',
18+
caret: '#797977',
19+
selection: '#36312e',
20+
selectionMatch: '#4f382b',
21+
gutterBackground: '#28211c',
22+
gutterForeground: '#666666',
23+
lineHighlight: 'rgba(255, 255, 255, 0.1)',
24+
...settings,
25+
},
26+
styles: [
27+
{ tag: [t.atom, t.number, t.link, t.bool], color: '#9b859d' },
28+
{ tag: t.comment, color: '#937121' },
29+
{ tag: [t.keyword, t.tagName], color: '#cf6a4c' },
30+
{ tag: t.string, color: '#f9ee98' },
31+
{ tag: t.bracket, color: '#9d9b97' },
32+
{ tag: [t.variableName], color: '#5ea6ea' },
33+
{ tag: t.definition(t.variableName), color: '#cf7d34' },
34+
{ tag: [t.function(t.variableName), t.className], color: '#cf7d34' },
35+
{ tag: [t.propertyName, t.attributeName], color: '#54be0d' },
36+
...styles,
37+
],
38+
});
39+
};
40+
41+
export const bespin = bespinInit();

0 commit comments

Comments
 (0)
Please sign in to comment.