Skip to content

Commit

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

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

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

## API

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

## Usage

```jsx
Expand Down
57 changes: 32 additions & 25 deletions themes/bespin/src/index.ts
Expand Up @@ -6,29 +6,36 @@
* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
*/
import { tags as t } from '@lezer/highlight';
import { createTheme } from '@uiw/codemirror-themes';
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes';

export const bespin = createTheme({
theme: 'dark',
settings: {
background: '#28211c',
foreground: '#9d9b97',
caret: '#797977',
selection: '#36312e',
selectionMatch: '#4f382b',
gutterBackground: '#28211c',
gutterForeground: '#666666',
lineHighlight: 'rgba(255, 255, 255, 0.1)',
},
styles: [
{ tag: [t.atom, t.number, t.link, t.bool], color: '#9b859d' },
{ tag: t.comment, color: '#937121' },
{ tag: [t.keyword, t.tagName], color: '#cf6a4c' },
{ tag: t.string, color: '#f9ee98' },
{ tag: t.bracket, color: '#9d9b97' },
{ tag: [t.variableName], color: '#5ea6ea' },
{ tag: t.definition(t.variableName), color: '#cf7d34' },
{ tag: [t.function(t.variableName), t.className], color: '#cf7d34' },
{ tag: [t.propertyName, t.attributeName], color: '#54be0d' },
],
});
export const bespinInit = (options?: CreateThemeOptions) => {
const { theme = 'dark', settings = {}, styles = [] } = options || {};
return createTheme({
theme: theme,
settings: {
background: '#28211c',
foreground: '#9d9b97',
caret: '#797977',
selection: '#36312e',
selectionMatch: '#4f382b',
gutterBackground: '#28211c',
gutterForeground: '#666666',
lineHighlight: 'rgba(255, 255, 255, 0.1)',
...settings,
},
styles: [
{ tag: [t.atom, t.number, t.link, t.bool], color: '#9b859d' },
{ tag: t.comment, color: '#937121' },
{ tag: [t.keyword, t.tagName], color: '#cf6a4c' },
{ tag: t.string, color: '#f9ee98' },
{ tag: t.bracket, color: '#9d9b97' },
{ tag: [t.variableName], color: '#5ea6ea' },
{ tag: t.definition(t.variableName), color: '#cf7d34' },
{ tag: [t.function(t.variableName), t.className], color: '#cf7d34' },
{ tag: [t.propertyName, t.attributeName], color: '#54be0d' },
...styles,
],
});
};

export const bespin = bespinInit();

0 comments on commit 0515402

Please sign in to comment.