Skip to content

Commit 82d86e5

Browse files
committedDec 7, 2022
feat(atomone): add atomoneInit method to atomone theme.
1 parent e6b66d0 commit 82d86e5

File tree

2 files changed

+59
-26
lines changed

2 files changed

+59
-26
lines changed
 

‎themes/atomone/README.md

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

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

2147
```jsx

‎themes/atomone/src/index.ts

+33-26
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,38 @@
55
* https://github.com/atom/one-dark-syntax
66
*/
77
import { tags as t } from '@lezer/highlight';
8-
import { createTheme } from '@uiw/codemirror-themes';
8+
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes';
99

10-
export const atomone = createTheme({
11-
theme: 'dark',
12-
settings: {
13-
background: '#272C35',
14-
foreground: '#9d9b97',
15-
caret: '#797977',
16-
selection: '#ffffff30',
17-
selectionMatch: '#2B323D',
18-
gutterBackground: '#272C35',
19-
gutterForeground: '#465063',
20-
lineHighlight: '#2B323D',
21-
},
22-
styles: [
23-
{
24-
tag: [t.function(t.variableName), t.function(t.propertyName), t.url, t.processingInstruction],
25-
color: 'hsl(207, 82%, 66%)',
10+
export const atomoneInit = (options?: CreateThemeOptions) => {
11+
const { theme = 'light', settings = {}, styles = [] } = options || {};
12+
return createTheme({
13+
theme: theme,
14+
settings: {
15+
background: '#272C35',
16+
foreground: '#9d9b97',
17+
caret: '#797977',
18+
selection: '#ffffff30',
19+
selectionMatch: '#2B323D',
20+
gutterBackground: '#272C35',
21+
gutterForeground: '#465063',
22+
lineHighlight: '#2B323D',
23+
...settings,
2624
},
27-
{ tag: [t.tagName, t.heading], color: '#e06c75' },
28-
{ tag: t.comment, color: '#54636D' },
29-
{ tag: [t.propertyName], color: 'hsl(220, 14%, 71%)' },
30-
{ tag: [t.attributeName, t.number], color: 'hsl( 29, 54%, 61%)' },
31-
{ tag: t.className, color: 'hsl( 39, 67%, 69%)' },
32-
{ tag: t.keyword, color: 'hsl(286, 60%, 67%)' },
33-
{ tag: [t.string, t.regexp, t.special(t.propertyName)], color: '#98c379' },
34-
],
35-
});
25+
styles: [
26+
{
27+
tag: [t.function(t.variableName), t.function(t.propertyName), t.url, t.processingInstruction],
28+
color: 'hsl(207, 82%, 66%)',
29+
},
30+
{ tag: [t.tagName, t.heading], color: '#e06c75' },
31+
{ tag: t.comment, color: '#54636D' },
32+
{ tag: [t.propertyName], color: 'hsl(220, 14%, 71%)' },
33+
{ tag: [t.attributeName, t.number], color: 'hsl( 29, 54%, 61%)' },
34+
{ tag: t.className, color: 'hsl( 39, 67%, 69%)' },
35+
{ tag: t.keyword, color: 'hsl(286, 60%, 67%)' },
36+
{ tag: [t.string, t.regexp, t.special(t.propertyName)], color: '#98c379' },
37+
...styles,
38+
],
39+
});
40+
};
41+
42+
export const atomone = atomoneInit();

0 commit comments

Comments
 (0)
Please sign in to comment.