Skip to content

Commit

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

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

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

## API

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

## Usage

```jsx
Expand Down
65 changes: 36 additions & 29 deletions themes/bbedit/src/index.ts
@@ -1,31 +1,38 @@
import { tags as t } from '@lezer/highlight';
import { createTheme } from '@uiw/codemirror-themes';
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes';

export const bbedit = createTheme({
theme: 'light',
settings: {
background: '#FFFFFF',
foreground: '#000000',
caret: '#FBAC52',
selection: '#FFD420',
selectionMatch: '#FFD420',
gutterBackground: '#f5f5f5',
gutterForeground: '#4D4D4C',
lineHighlight: '#00000012',
},
styles: [
{ tag: [t.meta, t.comment], color: '#804000' },
{ tag: [t.keyword, t.strong], color: '#0000FF' },
{ tag: [t.number], color: '#FF0080' },
{ tag: [t.string], color: '#FF0080' },
{ tag: [t.variableName], color: '#006600' },
{ tag: [t.escape], color: '#33CC33' },
{ tag: [t.tagName], color: '#1C02FF' },
{ tag: [t.heading], color: '#0C07FF' },
{ tag: [t.quote], color: '#000000' },
{ tag: [t.list], color: '#B90690' },
{ tag: [t.documentMeta], color: '#888888' },
{ tag: [t.function(t.variableName)], color: '#0000A2' },
{ tag: [t.definition(t.typeName), t.typeName], color: '#6D79DE' },
],
});
export const bbeditInit = (options?: CreateThemeOptions) => {
const { theme = 'light', settings = {}, styles = [] } = options || {};
return createTheme({
theme: theme,
settings: {
background: '#FFFFFF',
foreground: '#000000',
caret: '#FBAC52',
selection: '#FFD420',
selectionMatch: '#FFD420',
gutterBackground: '#f5f5f5',
gutterForeground: '#4D4D4C',
lineHighlight: '#00000012',
...settings,
},
styles: [
{ tag: [t.meta, t.comment], color: '#804000' },
{ tag: [t.keyword, t.strong], color: '#0000FF' },
{ tag: [t.number], color: '#FF0080' },
{ tag: [t.string], color: '#FF0080' },
{ tag: [t.variableName], color: '#006600' },
{ tag: [t.escape], color: '#33CC33' },
{ tag: [t.tagName], color: '#1C02FF' },
{ tag: [t.heading], color: '#0C07FF' },
{ tag: [t.quote], color: '#000000' },
{ tag: [t.list], color: '#B90690' },
{ tag: [t.documentMeta], color: '#888888' },
{ tag: [t.function(t.variableName)], color: '#0000A2' },
{ tag: [t.definition(t.typeName), t.typeName], color: '#6D79DE' },
...styles,
],
});
};

export const bbedit = bbeditInit();

0 comments on commit e6b66d0

Please sign in to comment.