Skip to content

Commit 058a8ac

Browse files
authoredNov 10, 2022
feat(theme): Gruvbox theme (#402)
* theme src * theme package.json * theme tsconfig.json * theme readme
1 parent 579f39b commit 058a8ac

File tree

4 files changed

+156
-0
lines changed

4 files changed

+156
-0
lines changed
 

‎themes/gruvbox/README.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<!--rehype:ignore:start-->
2+
3+
# Gruvbox Dark Theme
4+
5+
<!--rehype:ignore:end-->
6+
7+
<!-- [![npm version]()]() -->
8+
9+
<!-- <a href=""> -->
10+
<!-- <img width="436" alt="codemirror-theme-gruvbox-dark" src=""> -->
11+
<!-- </a> -->
12+
13+
## Install
14+
15+
```bash
16+
npm install @uiw/codemirror-theme-gruvbox-dark --save
17+
```
18+
19+
## Usage
20+
21+
```jsx
22+
import CodeMirror from '@uiw/react-codemirror'
23+
import { gruvboxDark } from '@uiw/codemirror-theme-gruvbox-dark'
24+
import { javascript } from '@codemirror/lang-javascript'
25+
26+
function App() {
27+
return (
28+
<CodeMirror
29+
value="console.log('hello world!');"
30+
height='200px'
31+
theme={gruvboxDark}
32+
extensions={[javascript({ jsx: true })]}
33+
/>
34+
)
35+
}
36+
export default App
37+
```
38+
39+
```js
40+
import { EditorView } from '@codemirror/view'
41+
import { EditorState } from '@codemirror/state'
42+
import { javascript } from '@codemirror/lang-javascript'
43+
import { gruvboxDark } from '@uiw/codemirror-theme-gruvbox-dark'
44+
45+
const state = EditorState.create({
46+
doc: 'my source code',
47+
extensions: [gruvboxDark, javascript({ jsx: true })],
48+
})
49+
50+
const view = new EditorView({
51+
parent: document.querySelector('#editor'),
52+
state,
53+
})
54+
```
55+
56+
## Contributors
57+
58+
As always, thanks to our amazing contributors!
59+
60+
<a href="https://github.com/uiwjs/react-codemirror/graphs/contributors">
61+
<img src="https://uiwjs.github.io/react-codemirror/CONTRIBUTORS.svg" />
62+
</a>
63+
64+
Made with [github-action-contributors](https://github.com/jaywcjlove/github-action-contributors).
65+
66+
## License
67+
68+
Licensed under the MIT License.

‎themes/gruvbox/package.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "@uiw/codemirror-theme-gruvbox-dark",
3+
"version": "4.13.0",
4+
"description": "Theme gruvbox-dark for CodeMirror.",
5+
"homepage": "https://uiwjs.github.io/react-codemirror/#/theme/data/gruvbox-dark",
6+
"author": "kenny wong <wowohoo@qq.com>",
7+
"license": "MIT",
8+
"main": "./cjs/index.js",
9+
"module": "./esm/index.js",
10+
"scripts": {
11+
"watch": "tsbb watch",
12+
"build": "tsbb build"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/uiwjs/react-codemirror.git"
17+
},
18+
"files": [
19+
"src",
20+
"esm",
21+
"cjs"
22+
],
23+
"dependencies": {
24+
"@uiw/codemirror-themes": "4.13.0"
25+
},
26+
"keywords": [
27+
"codemirror",
28+
"codemirror6",
29+
"theme",
30+
"gruvbox",
31+
"syntax",
32+
"ide",
33+
"code"
34+
],
35+
"jest": {
36+
"coverageReporters": [
37+
"lcov",
38+
"json-summary"
39+
]
40+
}
41+
}

‎themes/gruvbox/src/index.ts

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* @name gruvbox-dark
3+
* @author morhetz
4+
* Name: Gruvbox
5+
* From github.com/codemirror/codemirror5/blob/master/theme/gruvbox-dark.css
6+
*/
7+
import { tags as t } from '@lezer/highlight';
8+
import { createTheme } from '@uiw/codemirror-themes';
9+
10+
export const gruvboxDark = createTheme({
11+
theme: 'dark',
12+
settings: {
13+
background: '#282828',
14+
foreground: '#ebdbb2',
15+
caret: '#ebdbb2',
16+
selection: '#bdae93',
17+
selectionMatch: '#bdae93',
18+
lineHighlight: '#3c3836',
19+
gutterBackground: '#282828',
20+
gutterForeground: '#7c6f64',
21+
},
22+
styles: [
23+
{ tag: t.comment, color: '#928374' },
24+
{ tag: t.variableName, color: '#ebdbb2' },
25+
{ tag: [t.string, t.special(t.brace)], color: '#b8bb26' },
26+
{ tag: t.number, color: '#d3869b' },
27+
{ tag: t.bool, color: '#d3869b' },
28+
{ tag: t.null, color: '#d3869b' },
29+
{ tag: t.keyword, color: '#f84934' },
30+
{ tag: t.operator, color: '#ebdbb2' },
31+
{ tag: t.className, color: '#8ec07c' },
32+
{ tag: t.definition(t.typeName), color: '#f84934' },
33+
{ tag: t.typeName, color: '#f84934' },
34+
{ tag: t.angleBracket, color: '#fe8019' },
35+
{ tag: t.tagName, color: '#fe8019' },
36+
{ tag: t.attributeName, color: '#8ec07c' },
37+
],
38+
});

‎themes/gruvbox/tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../tsconfig",
3+
"include": ["src"],
4+
"compilerOptions": {
5+
"outDir": "./cjs",
6+
"baseUrl": ".",
7+
"noEmit": false
8+
}
9+
}

0 commit comments

Comments
 (0)
Please sign in to comment.