Skip to content

Commit

Permalink
feat(theme): add material theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Dec 5, 2022
1 parent 0eb8053 commit a2fe1d8
Show file tree
Hide file tree
Showing 12 changed files with 263 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -165,6 +165,12 @@ jobs:
token: ${{ secrets.NPM_TOKEN }}
package: ./themes/gruvbox/package.json

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

- name: 📦 @uiw/codemirror-theme-nord publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
Expand Down Expand Up @@ -429,6 +435,18 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

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

- run: npm publish
working-directory: themes/material
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
1 change: 1 addition & 0 deletions core/README.md
Expand Up @@ -64,6 +64,7 @@ npm install @uiw/react-codemirror --save
| `@uiw/codemirror-theme-eclipse` | [![npm version](https://img.shields.io/npm/v/@uiw/codemirror-theme-eclipse.svg)](https://www.npmjs.com/package/@uiw/codemirror-theme-eclipse) [![NPM Downloads](https://img.shields.io/npm/dm/@uiw/codemirror-theme-eclipse.svg?style=flat)](https://www.npmjs.com/package/@uiw/codemirror-theme-eclipse) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/eclipse) |
| `@uiw/codemirror-theme-github` | [![npm version](https://img.shields.io/npm/v/@uiw/codemirror-theme-github.svg)](https://www.npmjs.com/package/@uiw/codemirror-theme-github) [![NPM Downloads](https://img.shields.io/npm/dm/@uiw/codemirror-theme-github.svg?style=flat)](https://www.npmjs.com/package/@uiw/codemirror-theme-github) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/github) |
| `@uiw/codemirror-theme-gruvbox-dark` | [![npm version](https://img.shields.io/npm/v/@uiw/codemirror-theme-gruvbox-dark.svg)](https://www.npmjs.com/package/@uiw/codemirror-theme-gruvbox-dark) [![NPM Downloads](https://img.shields.io/npm/dm/@uiw/codemirror-theme-gruvbox-dark.svg?style=flat)](https://www.npmjs.com/package/@uiw/codemirror-theme-gruvbox-dark) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/gruvbox/dark) |
| `@uiw/codemirror-theme-material` | [![npm version](https://img.shields.io/npm/v/@uiw/codemirror-theme-material.svg)](https://www.npmjs.com/package/@uiw/codemirror-theme-material) [![NPM Downloads](https://img.shields.io/npm/dm/@uiw/codemirror-theme-material.svg?style=flat)](https://www.npmjs.com/package/@uiw/codemirror-theme-material) | [`#preview`](https://uiwjs.github.io/react-codemirror/#/theme/data/material) |
| `@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-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) |
Expand Down
1 change: 1 addition & 0 deletions themes/all/README.md
Expand Up @@ -70,6 +70,7 @@ export * from '@uiw/codemirror-theme-duotone';
export * from '@uiw/codemirror-theme-eclipse';
export * from '@uiw/codemirror-theme-github';
export * from '@uiw/codemirror-theme-gruvbox-dark';
export * from '@uiw/codemirror-theme-material';
export * from '@uiw/codemirror-theme-nord';
export * from '@uiw/codemirror-theme-okaidia';
export * from '@uiw/codemirror-theme-sublime';
Expand Down
1 change: 1 addition & 0 deletions themes/all/package.json
Expand Up @@ -32,6 +32,7 @@
"@uiw/codemirror-theme-eclipse": "4.16.0",
"@uiw/codemirror-theme-github": "4.16.0",
"@uiw/codemirror-theme-gruvbox-dark": "4.16.0",
"@uiw/codemirror-theme-material": "4.16.0",
"@uiw/codemirror-theme-nord": "4.16.0",
"@uiw/codemirror-theme-okaidia": "4.16.0",
"@uiw/codemirror-theme-sublime": "4.16.0",
Expand Down
1 change: 1 addition & 0 deletions themes/all/src/index.ts
Expand Up @@ -9,6 +9,7 @@ export * from '@uiw/codemirror-theme-duotone';
export * from '@uiw/codemirror-theme-eclipse';
export * from '@uiw/codemirror-theme-github';
export * from '@uiw/codemirror-theme-gruvbox-dark';
export * from '@uiw/codemirror-theme-material';
export * from '@uiw/codemirror-theme-nord';
export * from '@uiw/codemirror-theme-okaidia';
export * from '@uiw/codemirror-theme-sublime';
Expand Down
68 changes: 68 additions & 0 deletions themes/material/README.md
@@ -0,0 +1,68 @@
<!--rehype:ignore:start-->

# Material Theme

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

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

<a href="https://uiwjs.github.io/react-codemirror/#/theme/data/material">
<img width="436" alt="codemirror-theme-material" src="https://user-images.githubusercontent.com/1680273/205537793-79f9c99c-831a-4ce3-8189-78b42896656f.png">
</a>

## Install

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

## Usage

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

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

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

const state = EditorState.create({
doc: 'my source code',
extensions: [material, 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.
41 changes: 41 additions & 0 deletions themes/material/package.json
@@ -0,0 +1,41 @@
{
"name": "@uiw/codemirror-theme-material",
"version": "4.16.0",
"description": "Theme material for CodeMirror.",
"homepage": "https://uiwjs.github.io/react-codemirror/#/theme/data/material",
"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.16.0"
},
"keywords": [
"codemirror",
"codemirror6",
"theme",
"material",
"syntax",
"ide",
"code"
],
"jest": {
"coverageReporters": [
"lcov",
"json-summary"
]
}
}
112 changes: 112 additions & 0 deletions themes/material/src/index.ts
@@ -0,0 +1,112 @@
import { tags as t } from '@lezer/highlight';
import { createTheme } from '@uiw/codemirror-themes';

export const material = createTheme({
theme: 'dark',
settings: {
background: '#2e3235',
foreground: '#bdbdbd',
caret: '#a0a4ae',
selection: '#d7d4f0',
selectionMatch: '#d7d4f0',
gutterBackground: '#2e3235',
gutterForeground: '#999',
gutterActiveForeground: '#4f5b66',
lineHighlight: '#545b61',
},
styles: [
{ tag: t.keyword, color: '#cf6edf' },
{
tag: [t.name, t.deleted, t.character, t.macroName],
color: '#56c8d8',
},
{ tag: [t.propertyName], color: '#facf4e' },
{ tag: [t.variableName], color: '#bdbdbd' },
{ tag: [t.function(t.variableName)], color: '#56c8d8' },
{ tag: [t.labelName], color: '#cf6edf' },
{
tag: [t.color, t.constant(t.name), t.standard(t.name)],
color: '#facf4e',
},
{ tag: [t.definition(t.name), t.separator], color: '#fa5788' },
{ tag: [t.brace], color: '#cf6edf' },
{
tag: [t.annotation],
color: '#ff5f52',
},
{
tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace],
color: '#ffad42',
},
{
tag: [t.typeName, t.className],
color: '#ffad42',
},
{
tag: [t.operator, t.operatorKeyword],
color: '#7186f0',
},
{
tag: [t.tagName],
color: '#99d066',
},
{
tag: [t.squareBracket],
color: '#ff5f52',
},
{
tag: [t.angleBracket],
color: '#606f7a',
},
{
tag: [t.attributeName],
color: '#bdbdbd',
},
{
tag: [t.regexp],
color: '#ff5f52',
},
{
tag: [t.quote],
color: '#6abf69',
},
{ tag: [t.string], color: '#99d066' },
{
tag: t.link,
color: '#56c8d8',
textDecoration: 'underline',
textUnderlinePosition: 'under',
},
{
tag: [t.url, t.escape, t.special(t.string)],
color: '#facf4e',
},
{ tag: [t.meta], color: '#707d8b' },
{ tag: [t.comment], color: '#707d8b', fontStyle: 'italic' },
{ tag: t.monospace, color: '#bdbdbd' },
{ tag: t.strong, fontWeight: 'bold', color: '#ff5f52' },
{ tag: t.emphasis, fontStyle: 'italic', color: '#99d066' },
{ tag: t.strikethrough, textDecoration: 'line-through' },
{ tag: t.heading, fontWeight: 'bold', color: '#facf4e' },
{ tag: t.heading1, fontWeight: 'bold', color: '#facf4e' },
{
tag: [t.heading2, t.heading3, t.heading4],
fontWeight: 'bold',
color: '#facf4e',
},
{
tag: [t.heading5, t.heading6],
color: '#facf4e',
},
{ tag: [t.atom, t.bool, t.special(t.variableName)], color: '#56c8d8' },
{
tag: [t.processingInstruction, t.inserted],
color: '#ff5f52',
},
{
tag: [t.contentSeparator],
color: '#56c8d8',
},
{ tag: t.invalid, color: '#606f7a', borderBottom: `1px dotted #ff5f52` },
],
});
9 changes: 9 additions & 0 deletions themes/material/tsconfig.json
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig",
"include": ["src"],
"compilerOptions": {
"outDir": "./cjs",
"baseUrl": ".",
"noEmit": false
}
}
6 changes: 6 additions & 0 deletions themes/theme/README.md
Expand Up @@ -192,6 +192,12 @@ export default App;
<img width="436" alt="codemirror-theme-eclipse" src="https://user-images.githubusercontent.com/1680273/205499803-e1e2e214-dc3e-488a-9037-ba979e5ce199.png">
</a>

**material**

<a href="https://uiwjs.github.io/react-codemirror/#/theme/data/material">
<img width="436" alt="codemirror-theme-material" src="https://user-images.githubusercontent.com/1680273/205537793-79f9c99c-831a-4ce3-8189-78b42896656f.png">
</a>

**nord**

<a href="https://uiwjs.github.io/react-codemirror/#/theme/data/nord">
Expand Down
1 change: 1 addition & 0 deletions www/package.json
Expand Up @@ -54,6 +54,7 @@
"@uiw/codemirror-theme-eclipse": "4.16.0",
"@uiw/codemirror-theme-github": "4.16.0",
"@uiw/codemirror-theme-gruvbox-dark": "4.16.0",
"@uiw/codemirror-theme-material": "4.16.0",
"@uiw/codemirror-theme-nord": "4.16.0",
"@uiw/codemirror-theme-okaidia": "4.16.0",
"@uiw/codemirror-theme-sublime": "4.16.0",
Expand Down
4 changes: 4 additions & 0 deletions www/src/pages/theme/themes/Datas.ts
Expand Up @@ -8,6 +8,7 @@ import darculaMd from '@uiw/codemirror-theme-darcula/README.md';
import duotoneMd from '@uiw/codemirror-theme-duotone/README.md';
import githubMd from '@uiw/codemirror-theme-github/README.md';
import gruvboxDarkMd from '@uiw/codemirror-theme-gruvbox-dark/README.md';
import materialMd from '@uiw/codemirror-theme-material/README.md';
import nordMd from '@uiw/codemirror-theme-nord/README.md';
import eclipseMd from '@uiw/codemirror-theme-eclipse/README.md';
import bespinMd from '@uiw/codemirror-theme-bespin/README.md';
Expand All @@ -24,6 +25,7 @@ import { dracula } from '@uiw/codemirror-theme-dracula';
import { darcula } from '@uiw/codemirror-theme-darcula';
import { eclipse } from '@uiw/codemirror-theme-eclipse';
import { bespin } from '@uiw/codemirror-theme-bespin';
import { material } from '@uiw/codemirror-theme-material';
import { vscodeDark } from '@uiw/codemirror-theme-vscode';
import { duotoneLight, duotoneDark } from '@uiw/codemirror-theme-duotone';
import { githubLight, githubDark } from '@uiw/codemirror-theme-github';
Expand All @@ -47,6 +49,7 @@ export const mdSource = {
githubDark: githubMd.source,
gruvboxDark: gruvboxDarkMd.source,
gruvboxLight: gruvboxDarkMd.source,
material: materialMd.source,
nord: nordMd.source,
okaidia: okaidiaMd.source,
sublime: sublimeMd.source,
Expand All @@ -70,6 +73,7 @@ export const themeData = {
githubDark,
gruvboxDark,
gruvboxLight,
material,
nord,
okaidia,
sublime,
Expand Down

0 comments on commit a2fe1d8

Please sign in to comment.