Skip to content

Commit

Permalink
feat(theme): add TokyoNightStorm theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Dec 7, 2022
1 parent 4af4add commit e67f5ee
Show file tree
Hide file tree
Showing 10 changed files with 297 additions and 24 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -136,6 +136,12 @@ jobs:
token: ${{ secrets.NPM_TOKEN }}
package: ./themes/atomone/package.json

- name: 📦 @uiw/codemirror-theme-aura publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
package: ./themes/aura/package.json

- name: 📦 @uiw/codemirror-theme-bbedit publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
Expand Down Expand Up @@ -178,6 +184,12 @@ jobs:
token: ${{ secrets.NPM_TOKEN }}
package: ./themes/material/package.json

- name: 📦 @uiw/codemirror-theme-noctis-lilac publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
package: ./themes/noctis-lilac/package.json

- name: 📦 @uiw/codemirror-theme-nord publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
Expand All @@ -202,6 +214,18 @@ jobs:
token: ${{ secrets.NPM_TOKEN }}
package: ./themes/sublime/package.json

- name: 📦 @uiw/codemirror-theme-tokyo-night publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
package: ./themes/tokyo-night/package.json

- name: 📦 @uiw/codemirror-theme-tokyo-night-storm publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
package: ./themes/tokyo-night-storm/package.json

- name: 📦 @uiw/codemirror-theme-vscode publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
Expand Down Expand Up @@ -356,6 +380,19 @@ jobs:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}


- name: Modify @uiw/codemirror-theme-aura => @uiwjs/codemirror-theme-aura
uses: jaywcjlove/github-action-package@main
with:
path: themes/aura/package.json
rename: "@uiwjs/codemirror-theme-aura"

- run: npm publish
working-directory: themes/aura
continue-on-error: true
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}


- name: Modify @uiw/codemirror-theme-bbedit => @uiwjs/codemirror-theme-bbedit
uses: jaywcjlove/github-action-package@main
with:
Expand Down Expand Up @@ -468,6 +505,18 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Modify @uiw/codemirror-theme-noctis-lilac => @uiwjs/codemirror-theme-noctis-lilac
uses: jaywcjlove/github-action-package@main
with:
path: themes/noctis-lilac/package.json
rename: '@uiwjs/codemirror-theme-noctis-lilac'

- run: npm publish
working-directory: themes/noctis-lilac
continue-on-error: true
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Modify @uiw/codemirror-theme-nord => @uiwjs/codemirror-theme-nord
uses: jaywcjlove/github-action-package@main
with:
Expand Down Expand Up @@ -516,6 +565,30 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Modify @uiw/codemirror-theme-tokyo-night => @uiwjs/codemirror-theme-tokyo-night
uses: jaywcjlove/github-action-package@main
with:
path: themes/tokyo-night/package.json
rename: "@uiwjs/codemirror-theme-tokyo-night"

- run: npm publish
working-directory: themes/tokyo-night
continue-on-error: true
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Modify @uiw/codemirror-theme-tokyo-night-storm => @uiwjs/codemirror-theme-tokyo-night-storm
uses: jaywcjlove/github-action-package@main
with:
path: themes/tokyo-night-storm/package.json
rename: "@uiwjs/codemirror-theme-tokyo-night-storm"

- run: npm publish
working-directory: themes/tokyo-night-storm
continue-on-error: true
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Modify @uiw/codemirror-theme-vscode => @uiwjs/codemirror-theme-vscode
uses: jaywcjlove/github-action-package@main
with:
Expand Down
49 changes: 25 additions & 24 deletions core/README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions themes/all/package.json
Expand Up @@ -40,6 +40,7 @@
"@uiw/codemirror-theme-solarized": "4.18.2",
"@uiw/codemirror-theme-sublime": "4.18.2",
"@uiw/codemirror-theme-tokyo-night": "4.18.2",
"@uiw/codemirror-theme-tokyo-night-storm": "4.18.2",
"@uiw/codemirror-theme-vscode": "4.18.2",
"@uiw/codemirror-theme-xcode": "4.18.2",
"@uiw/codemirror-themes": "4.18.2"
Expand Down
1 change: 1 addition & 0 deletions themes/all/src/index.ts
Expand Up @@ -17,5 +17,6 @@ export * from '@uiw/codemirror-theme-okaidia';
export * from '@uiw/codemirror-theme-solarized';
export * from '@uiw/codemirror-theme-sublime';
export * from '@uiw/codemirror-theme-tokyo-night';
export * from '@uiw/codemirror-theme-tokyo-night-storm';
export * from '@uiw/codemirror-theme-vscode';
export * from '@uiw/codemirror-theme-xcode';
97 changes: 97 additions & 0 deletions themes/tokyo-night-storm/README.md
@@ -0,0 +1,97 @@
<!--rehype:ignore:start-->

# TokyoNightStorm Theme

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

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

<a href="https://uiwjs.github.io/react-codemirror/#/theme/data/tokyo-night-storm">
<img width="436" alt="codemirror-theme-tokyo-night-storm" src="https://user-images.githubusercontent.com/1680273/206094521-c3a51de1-8cb7-4f01-a9bd-6cfd04a3aa0d.png">
</a>

## Install

```bash
npm install @uiw/codemirror-theme-tokyo-night-storm --save
```

```jsx
import { tags as t } from '@lezer/highlight';
import { tokyoNightStorm, tokyoNightStormInit } from '@uiw/codemirror-theme-tokyo-night-storm';

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

## API

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

## Usage

```jsx
import CodeMirror from '@uiw/react-codemirror';
import { tokyoNightStorm } from '@uiw/codemirror-theme-tokyo-night-storm';
import { javascript } from '@codemirror/lang-javascript';

function App() {
return (
<CodeMirror
value="console.log('hello world!');"
height="200px"
theme={tokyoNightStorm}
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 { tokyoNightStorm } from '@uiw/codemirror-theme-tokyo-night-storm';

const state = EditorState.create({
doc: 'my source code',
extensions: [tokyoNightStorm, 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.
42 changes: 42 additions & 0 deletions themes/tokyo-night-storm/package.json
@@ -0,0 +1,42 @@
{
"name": "@uiw/codemirror-theme-tokyo-night-storm",
"version": "4.18.2",
"description": "Theme tokyo-night-storm for CodeMirror.",
"homepage": "https://uiwjs.github.io/react-codemirror/#/theme/data/tokyo-night-storm",
"author": "kenny wong <wowohoo@qq.com>",
"license": "MIT",
"main": "./cjs/index.js",
"module": "./esm/index.js",
"scripts": {
"watch": "tsbb watch",
"build": "tsbb build"
},
"repository": {
"type": "git",
"url": "https://github.com/uiwjs/react-codemirror.git"
},
"files": [
"src",
"esm",
"cjs"
],
"dependencies": {
"@uiw/codemirror-themes": "4.18.2"
},
"keywords": [
"codemirror",
"codemirror6",
"theme",
"tokyo-night",
"tokyo-night-storm",
"syntax",
"ide",
"code"
],
"jest": {
"coverageReporters": [
"lcov",
"json-summary"
]
}
}
46 changes: 46 additions & 0 deletions themes/tokyo-night-storm/src/index.ts
@@ -0,0 +1,46 @@
import { tags as t } from '@lezer/highlight';
import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes';

export const tokyoNightStormInit = (options?: CreateThemeOptions) => {
const { theme = 'dark', settings = {}, styles = [] } = options || {};
return createTheme({
theme: theme,
settings: {
background: '#24283b',
foreground: '#7982a9',
caret: '#c0caf5',
selection: '#6f7bb630',
selectionMatch: '#1f2335',
gutterBackground: '#24283b',
gutterForeground: '#7982a9',
gutterBorder: 'transparent',
lineHighlight: '#292e42',
...settings,
},
styles: [
{ tag: t.keyword, color: '#bb9af7' },
{ tag: [t.name, t.deleted, t.character, t.macroName], color: '#c0caf5' },
{ tag: [t.propertyName], color: '#7aa2f7' },
{ tag: [t.processingInstruction, t.string, t.inserted, t.special(t.string)], color: '#9ece6a' },
{ tag: [t.function(t.variableName), t.labelName], color: '#7aa2f7' },
{ tag: [t.color, t.constant(t.name), t.standard(t.name)], color: '#bb9af7' },
{ tag: [t.definition(t.name), t.separator], color: '#c0caf5' },
{ tag: [t.className], color: '#c0caf5' },
{ tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace], color: '#ff9e64' },
{ tag: [t.typeName], color: '#2ac3de', fontStyle: '#2ac3de' },
{ tag: [t.operator, t.operatorKeyword], color: '#bb9af7' },
{ tag: [t.url, t.escape, t.regexp, t.link], color: '#b4f9f8' },
{ tag: [t.meta, t.comment], color: '#565f89' },
{ tag: t.strong, fontWeight: 'bold' },
{ tag: t.emphasis, fontStyle: 'italic' },
{ tag: t.link, textDecoration: 'underline' },
{ tag: t.heading, fontWeight: 'bold', color: '#89ddff' },
{ tag: [t.atom, t.bool, t.special(t.variableName)], color: '#c0caf5' },
{ tag: t.invalid, color: '#ff5370' },
{ tag: t.strikethrough, textDecoration: 'line-through' },
...styles,
],
});
};

export const tokyoNightStorm = tokyoNightStormInit();
9 changes: 9 additions & 0 deletions themes/tokyo-night-storm/tsconfig.json
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig",
"include": ["src"],
"compilerOptions": {
"outDir": "./cjs",
"baseUrl": ".",
"noEmit": false
}
}
1 change: 1 addition & 0 deletions www/package.json
Expand Up @@ -62,6 +62,7 @@
"@uiw/codemirror-theme-solarized": "4.18.2",
"@uiw/codemirror-theme-sublime": "4.18.2",
"@uiw/codemirror-theme-tokyo-night": "4.18.2",
"@uiw/codemirror-theme-tokyo-night-storm": "4.18.2",
"@uiw/codemirror-theme-vscode": "4.18.2",
"@uiw/codemirror-theme-xcode": "4.18.2",
"@uiw/codemirror-themes": "4.18.2",
Expand Down
2 changes: 2 additions & 0 deletions www/src/pages/theme/themes/Datas.ts
Expand Up @@ -40,6 +40,7 @@ import { okaidia } from '@uiw/codemirror-theme-okaidia';
import { solarizedLight, solarizedDark } from '@uiw/codemirror-theme-solarized';
import { sublime } from '@uiw/codemirror-theme-sublime';
import { tokyoNight } from '@uiw/codemirror-theme-tokyo-night';
import { tokyoNightStorm } from '@uiw/codemirror-theme-tokyo-night-storm';
import { xcodeLight, xcodeDark } from '@uiw/codemirror-theme-xcode';

export const mdSource = {
Expand Down Expand Up @@ -95,6 +96,7 @@ export const themeData = {
solarizedDark,
sublime,
tokyoNight,
tokyoNightStorm,
vscodeDark,
xcodeLight,
xcodeDark,
Expand Down

0 comments on commit e67f5ee

Please sign in to comment.