Skip to content

Commit

Permalink
feat(darcula): add darculaInit method to darcula theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Dec 7, 2022
1 parent 8c4e397 commit 23c896c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 25 deletions.
26 changes: 26 additions & 0 deletions themes/darcula/README.md
Expand Up @@ -16,6 +16,32 @@
npm install @uiw/codemirror-theme-darcula --save
```

```jsx
import { tags as t } from '@lezer/highlight';
import { darcula, darculaInit } from '@uiw/codemirror-theme-darcula';

<CodeMirror theme={darcula} />
<CodeMirror
theme={darculaInit({
settings: {
caret: '#c6c6c6',
fontFamily: 'monospace',
},
styles: [
{ tag: t.comment, color: '#6272a4' },
]
})}
/>
```

## API

```tsx
import { CreateThemeOptions } from '@uiw/codemirror-themes';
export declare const darculaInit: (options?: CreateThemeOptions) => import('@codemirror/state').Extension;
export declare const darcula: import('@codemirror/state').Extension;
```

## Usage

```jsx
Expand Down
57 changes: 32 additions & 25 deletions themes/darcula/src/index.ts
Expand Up @@ -5,29 +5,36 @@
* From IntelliJ IDEA by JetBrains
*/
import { tags as t } from '@lezer/highlight';
import { createTheme } from '@uiw/codemirror-themes';
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes';

export const darcula = createTheme({
theme: 'dark',
settings: {
background: '#2B2B2B',
foreground: '#f8f8f2',
caret: '#FFFFFF',
selection: 'rgba(255, 255, 255, 0.1)',
selectionMatch: 'rgba(255, 255, 255, 0.2)',
gutterBackground: 'rgba(255, 255, 255, 0.1)',
gutterForeground: '#999',
lineHighlight: 'rgba(255, 255, 255, 0.1)',
},
styles: [
{ tag: [t.atom, t.number], color: '#bd93f9' },
{ tag: [t.comment], color: '#61A151' },
{ tag: [t.string], color: '#6A8759' },
{ tag: [t.variableName, t.operator], color: '#A9B7C6' },
{ tag: [t.meta, t.className], color: '#A9B7C6' },
{ tag: [t.propertyName], color: '#FFC66D' },
{ tag: [t.keyword], color: '#CC7832' },
{ tag: [t.tagName], color: '#ff79c6' },
{ tag: [t.typeName], color: '#ffb86c' },
],
});
export const darculaInit = (options?: CreateThemeOptions) => {
const { theme = 'light', settings = {}, styles = [] } = options || {};
return createTheme({
theme: theme,
settings: {
background: '#2B2B2B',
foreground: '#f8f8f2',
caret: '#FFFFFF',
selection: 'rgba(255, 255, 255, 0.1)',
selectionMatch: 'rgba(255, 255, 255, 0.2)',
gutterBackground: 'rgba(255, 255, 255, 0.1)',
gutterForeground: '#999',
lineHighlight: 'rgba(255, 255, 255, 0.1)',
...settings,
},
styles: [
{ tag: [t.atom, t.number], color: '#bd93f9' },
{ tag: [t.comment], color: '#61A151' },
{ tag: [t.string], color: '#6A8759' },
{ tag: [t.variableName, t.operator], color: '#A9B7C6' },
{ tag: [t.meta, t.className], color: '#A9B7C6' },
{ tag: [t.propertyName], color: '#FFC66D' },
{ tag: [t.keyword], color: '#CC7832' },
{ tag: [t.tagName], color: '#ff79c6' },
{ tag: [t.typeName], color: '#ffb86c' },
...styles,
],
});
};

export const darcula = darculaInit();

0 comments on commit 23c896c

Please sign in to comment.