Skip to content

Commit

Permalink
feat(theme): add red theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Aug 26, 2023
1 parent 6cd63b5 commit fbb07e1
Show file tree
Hide file tree
Showing 15 changed files with 253 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}


- name: 📦 @uiw/codemirror-theme-red publish to NPM
run: npm publish --access public
working-directory: ./themes/red/
continue-on-error: true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}


- name: 📦 @uiw/codemirror-theme-solarized publish to NPM
run: npm publish --access public
working-directory: ./themes/solarized/
Expand Down
1 change: 1 addition & 0 deletions core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ npm install @uiw/react-codemirror --save
| `@uiw/codemirror-theme-nord` | [![npm version](https://img.shields.io/npm/v/@uiw/codemirror-theme-nord.svg)](https://www.npmjs.com/package/@uiw/codemirror-theme-nord) [![NPM Downloads](https://img.shields.io/npm/dm/@uiw/codemirror-theme-nord.svg?style=flat)](https://www.npmjs.com/package/@uiw/codemirror-theme-nord) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/nord) |
| `@uiw/codemirror-theme-okaidia` | [![npm version](https://img.shields.io/npm/v/@uiw/codemirror-theme-okaidia.svg)](https://www.npmjs.com/package/@uiw/codemirror-theme-okaidia) [![NPM Downloads](https://img.shields.io/npm/dm/@uiw/codemirror-theme-okaidia.svg?style=flat)](https://www.npmjs.com/package/@uiw/codemirror-theme-okaidia) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/okaidia) |
| `@uiw/codemirror-theme-quietlight` | [![npm version](https://img.shields.io/npm/v/@uiw/codemirror-theme-quietlight.svg)](https://www.npmjs.com/package/@uiw/codemirror-theme-quietlight) [![NPM Downloads](https://img.shields.io/npm/dm/@uiw/codemirror-theme-quietlight.svg?style=flat)](https://www.npmjs.com/package/@uiw/codemirror-theme-quietlight) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/quietlight) |
| `@uiw/codemirror-theme-red` | [![npm version](https://img.shields.io/npm/v/@uiw/codemirror-theme-red.svg)](https://www.npmjs.com/package/@uiw/codemirror-theme-red) [![NPM Downloads](https://img.shields.io/npm/dm/@uiw/codemirror-theme-red.svg?style=flat)](https://www.npmjs.com/package/@uiw/codemirror-theme-red) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/red) |
| `@uiw/codemirror-theme-solarized` | [![npm version](https://img.shields.io/npm/v/@uiw/codemirror-theme-solarized.svg)](https://www.npmjs.com/package/@uiw/codemirror-theme-solarized) [![NPM Downloads](https://img.shields.io/npm/dm/@uiw/codemirror-theme-solarized.svg?style=flat)](https://www.npmjs.com/package/@uiw/codemirror-theme-solarized) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/solarized/dark) |
| `@uiw/codemirror-theme-sublime` | [![npm version](https://img.shields.io/npm/v/@uiw/codemirror-theme-sublime.svg)](https://www.npmjs.com/package/@uiw/codemirror-theme-sublime) [![NPM Downloads](https://img.shields.io/npm/dm/@uiw/codemirror-theme-sublime.svg?style=flat)](https://www.npmjs.com/package/@uiw/codemirror-theme-sublime) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/sublime) |
| `@uiw/codemirror-theme-tokyo-night` | [![npm version](https://img.shields.io/npm/v/@uiw/codemirror-theme-tokyo-night.svg)](https://www.npmjs.com/package/@uiw/codemirror-theme-tokyo-night) [![NPM Downloads](https://img.shields.io/npm/dm/@uiw/codemirror-theme-tokyo-night.svg?style=flat)](https://www.npmjs.com/package/@uiw/codemirror-theme-tokyo-night) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/tokyo-night) |
Expand Down
9 changes: 6 additions & 3 deletions themes/_scripts/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,17 @@ function format(data = {}, dark = false) {
const getString = (obj) => `export const config = ${JSON.stringify(obj, null, 2)};`;

;(async () => {
const themeQuietlight = format(require('./data/quietlight.json'))
const themeQuietlight = format(require('./data/quietlight.json'));
let themePath = '../quietlight/src/color.ts';
await FS.writeFile(themePath, getString(themeQuietlight));
console.log(`🎉 File \x1b[32;1m${themePath}\x1b[0m created.`);

const themeRed = format(require('./data/red.json'));
themePath = '../red/src/color.ts';
await FS.writeFile(themePath, getString(themeRed));
console.log(`🎉 File \x1b[32;1m${themePath}\x1b[0m created.`);


const themeRed = format(require('./data/red.json'), true)
console.log('~~~::', themeRed);
const themeSolarizedDark = format(require('./data/solarized.dark.json'), true)
console.log('~~~::', themeSolarizedDark);
const themeSolarizedLight = format(require('./data/solarized.light.json'))
Expand Down
7 changes: 7 additions & 0 deletions themes/all/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export * from '@uiw/codemirror-theme-noctis-lilac';
export * from '@uiw/codemirror-theme-nord';
export * from '@uiw/codemirror-theme-okaidia';
export * from '@uiw/codemirror-theme-quietlight';
export * from '@uiw/codemirror-theme-red';
export * from '@uiw/codemirror-theme-solarized';
export * from '@uiw/codemirror-theme-sublime';
export * from '@uiw/codemirror-theme-tokyo-night';
Expand Down Expand Up @@ -216,6 +217,12 @@ export * from '@uiw/codemirror-theme-xcode';
<img width="436" alt="codemirror-theme-okaidia" src="https://github.com/uiwjs/react-codemirror/assets/1680273/3137facb-8db7-4805-bd5c-9818d5ff49ae">
</a>

**red**

<a href="https://uiwjs.github.io/react-codemirror/#/theme/data/red">
<img width="436" alt="codemirror-theme-red" src="https://github.com/uiwjs/react-codemirror/assets/1680273/aef0a618-8c74-4466-9a04-35e368f582a7">
</a>

**solarized**

<a href="https://uiwjs.github.io/react-codemirror/#/theme/data/solarized/light">
Expand Down
2 changes: 2 additions & 0 deletions themes/all/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export * from '@uiw/codemirror-theme-material';
export * from '@uiw/codemirror-theme-noctis-lilac';
export * from '@uiw/codemirror-theme-nord';
export * from '@uiw/codemirror-theme-okaidia';
export * from '@uiw/codemirror-theme-quietlight';
export * from '@uiw/codemirror-theme-red';
export * from '@uiw/codemirror-theme-solarized';
export * from '@uiw/codemirror-theme-sublime';
export * from '@uiw/codemirror-theme-tokyo-night';
Expand Down
2 changes: 1 addition & 1 deletion themes/quietlight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"cjs"
],
"dependencies": {
"@uiw/codemirror-themes": "4.21.9"
"@uiw/codemirror-themes": "4.21.10"
},
"keywords": [
"codemirror",
Expand Down
1 change: 1 addition & 0 deletions themes/quietlight/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const defaultSettingsQuietlight: CreateThemeOptions['settings'] = {
selectionMatch: config.selection,
gutterBackground: config.background,
gutterForeground: config.foreground,
gutterBorder: 'transparent',
lineHighlight: config.activeLine,
};

Expand Down
96 changes: 96 additions & 0 deletions themes/red/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<!--rehype:ignore:start-->

# Red Theme

<!--rehype:ignore:end-->

[![npm version](https://img.shields.io/npm/v/@uiw/codemirror-theme-red.svg)](https://www.npmjs.com/package/@uiw/codemirror-theme-red)

Red theme for cm6, generated from [vscode themes](https://github.com/microsoft/vscode/blob/main/extensions/theme-red/themes/Red-color-theme.json).

<a href="https://uiwjs.github.io/react-codemirror/#/theme/data/red">
<img width="436" alt="codemirror-theme-red" src="https://github.com/uiwjs/react-codemirror/assets/1680273/aef0a618-8c74-4466-9a04-35e368f582a7">
</a>

## Install

```bash
npm install @uiw/codemirror-theme-red --save
```

```jsx
import { red, redInit } from '@uiw/codemirror-theme-red';

<CodeMirror theme={red} />
<CodeMirror
theme={redInit({
settings: {
caret: '#c6c6c6',
fontFamily: 'monospace',
}
})}
/>
```

## API

```tsx
import { CreateThemeOptions } from '@uiw/codemirror-themes';
export declare const defaultSettingsQuietlight: CreateThemeOptions['settings'];
export declare const redInit: (options?: Partial<CreateThemeOptions>) => import('@codemirror/state').Extension;
export declare const red: import('@codemirror/state').Extension;
```

## Usage

```jsx
import CodeMirror from '@uiw/react-codemirror';
import { red } from '@uiw/codemirror-theme-red';
import { javascript } from '@codemirror/lang-javascript';

function App() {
return (
<CodeMirror
value="console.log('hello world!');"
height="200px"
theme={red}
extensions={[javascript({ jsx: true })]}
onChange={(value, viewUpdate) => {
console.log('value:', value);
}}
/>
);
}
export default App;
```

```js
import { EditorView } from '@codemirror/view';
import { EditorState } from '@codemirror/state';
import { javascript } from '@codemirror/lang-javascript';
import { red } from '@uiw/codemirror-theme-red';

const state = EditorState.create({
doc: 'my source code',
extensions: [red, javascript({ jsx: true })],
});

const view = new EditorView({
parent: document.querySelector('#editor'),
state,
});
```

## Contributors

As always, thanks to our amazing contributors!

<a href="https://github.com/uiwjs/react-codemirror/graphs/contributors">
<img src="https://uiwjs.github.io/react-codemirror/CONTRIBUTORS.svg" />
</a>

Made with [github-action-contributors](https://github.com/jaywcjlove/github-action-contributors).

## License

Licensed under the MIT License.
36 changes: 36 additions & 0 deletions themes/red/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@uiw/codemirror-theme-red",
"version": "4.21.10",
"description": "Theme red for CodeMirror.",
"homepage": "https://uiwjs.github.io/react-codemirror/#/theme/data/red",
"author": "kenny wong <[email protected]>",
"license": "MIT",
"main": "./cjs/index.js",
"module": "./esm/index.js",
"scripts": {
"watch": "tsbb watch src/*.ts --use-babel",
"build": "tsbb build src/*.ts --use-babel"
},
"repository": {
"type": "git",
"url": "https://github.com/uiwjs/react-codemirror.git"
},
"files": [
"src",
"esm",
"cjs"
],
"dependencies": {
"@uiw/codemirror-themes": "4.21.10"
},
"keywords": [
"codemirror",
"codemirror-theme",
"codemirror6",
"theme",
"red",
"syntax",
"ide",
"code"
]
}
23 changes: 23 additions & 0 deletions themes/red/src/color.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export const config = {
background: '#390000',
foreground: '#F8F8F8',
selection: '#750000',
cursor: '#970000',
dropdownBackground: '#580000',
activeLine: '#ff000033',
matchingBracket: '#ff000033',
keyword: '#f12727ff',
storage: '#ff6262ff',
variable: '#fb9a4bff',
parameter: '#fb9a4bff',
function: '#ffb454ff',
string: '#cd8d8dff',
constant: '#ec0d1e',
type: '#9df39fff',
class: '#fec758ff',
number: '#994646ff',
comment: '#e7c0c0ff',
heading: '#fec758ff',
invalid: '#ffffffff',
regexp: '#ffb454ff',
};
50 changes: 50 additions & 0 deletions themes/red/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { tags as t } from '@lezer/highlight';
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes';
import { config } from './color';

export const defaultSettingsRed: CreateThemeOptions['settings'] = {
background: config.background,
foreground: config.foreground,
caret: config.cursor,
selection: config.selection,
selectionMatch: config.selection,
gutterBackground: config.background,
gutterForeground: config.foreground,
lineHighlight: config.activeLine,
};

export const redInit = (options?: Partial<CreateThemeOptions>) => {
const { theme = 'dark', settings = {}, styles = [] } = options || {};
return createTheme({
theme: theme,
settings: {
...defaultSettingsRed,
...settings,
},
styles: [
{ tag: t.keyword, color: config.keyword },
{ tag: [t.name, t.deleted, t.character, t.macroName], color: config.variable },
{ tag: [t.propertyName], color: config.function },
{ tag: [t.processingInstruction, t.string, t.inserted, t.special(t.string)], color: config.string },
{ tag: [t.function(t.variableName), t.labelName], color: config.function },
{ tag: [t.color, t.constant(t.name), t.standard(t.name)], color: config.constant },
{ tag: [t.definition(t.name), t.separator], color: config.variable },
{ tag: [t.className], color: config.class },
{ tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace], color: config.number },
{ tag: [t.typeName], color: config.type, fontStyle: config.type },
{ tag: [t.operator, t.operatorKeyword], color: config.keyword },
{ tag: [t.url, t.escape, t.regexp, t.link], color: config.regexp },
{ tag: [t.meta, t.comment], color: config.comment },
{ tag: t.strong, fontWeight: 'bold' },
{ tag: t.emphasis, fontStyle: 'italic' },
{ tag: t.link, textDecoration: 'underline' },
{ tag: t.heading, fontWeight: 'bold', color: config.heading },
{ tag: [t.atom, t.bool, t.special(t.variableName)], color: config.variable },
{ tag: t.invalid, color: config.invalid },
{ tag: t.strikethrough, textDecoration: 'line-through' },
...styles,
],
});
};

export const red = redInit();
9 changes: 9 additions & 0 deletions themes/red/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig",
"include": ["src"],
"compilerOptions": {
"outDir": "./cjs",
"baseUrl": ".",
"noEmit": false
}
}
1 change: 1 addition & 0 deletions www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"@uiw/codemirror-theme-nord": "4.21.10",
"@uiw/codemirror-theme-okaidia": "4.21.10",
"@uiw/codemirror-theme-quietlight": "4.21.10",
"@uiw/codemirror-theme-red": "4.21.10",
"@uiw/codemirror-theme-solarized": "4.21.10",
"@uiw/codemirror-theme-sublime": "4.21.10",
"@uiw/codemirror-theme-tokyo-night": "4.21.10",
Expand Down
2 changes: 2 additions & 0 deletions www/src/pages/theme/themes/Datas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { githubLight, githubDark } from '@uiw/codemirror-theme-github';
import { gruvboxDark, gruvboxLight } from '@uiw/codemirror-theme-gruvbox-dark';
import { nord } from '@uiw/codemirror-theme-nord';
import { okaidia } from '@uiw/codemirror-theme-okaidia';
import { red } from '@uiw/codemirror-theme-red';
import { quietlight } from '@uiw/codemirror-theme-quietlight';
import { solarizedLight, solarizedDark } from '@uiw/codemirror-theme-solarized';
import { sublime } from '@uiw/codemirror-theme-sublime';
Expand Down Expand Up @@ -47,6 +48,7 @@ export const themeData = {
noctisLilac,
nord,
okaidia,
red,
quietlight,
solarizedLight,
solarizedDark,
Expand Down
10 changes: 10 additions & 0 deletions www/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,16 @@ export const routes: MenuRouteObject[] = [
/>
),
},
{
path: 'data/red',
label: 'red',
element: (
<Preview
themePkg="@uiw/codemirror-theme-red"
path={() => import('@uiw/codemirror-theme-red/README.md')}
/>
),
},
{
path: 'data/solarized/light',
label: 'solarized light',
Expand Down

0 comments on commit fbb07e1

Please sign in to comment.