Skip to content

Commit 10ff7ec

Browse files
committed
feat: add gruvbox theme.
1 parent 9908adb commit 10ff7ec

File tree

9 files changed

+80
-4
lines changed

9 files changed

+80
-4
lines changed

core/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,29 @@ import { nordTheme } from '@uiw/react-json-view/nord';
8989
import { githubLightTheme } from '@uiw/react-json-view/githubLight';
9090
import { githubDarkTheme } from '@uiw/react-json-view/githubDark';
9191
import { vscodeTheme } from '@uiw/react-json-view/vscode';
92+
import { gruvboxTheme } from '@uiw/react-json-view/gruvbox';
9293

9394
const object = {
9495
string: 'Lorem ipsum dolor sit amet',
9596
integer: 42,
9697
float: 114.514,
9798
boolean: true,
9899
null: null,
100+
nan: NaN,
99101
url: new URL('https://example.com'),
100102
}
101103

104+
const style = { display: 'grid', gap: '1rem', gridTemplateColumns: 'repeat(auto-fill, minmax(250px, 1fr))' };
105+
102106
export default function Demo() {
103107
return (
104-
<div style={{ display: 'grid', gap: '1rem', gridTemplateColumns: 'repeat(auto-fill, minmax(250px, 1fr))' }}>
108+
<div style={style}>
105109
<JsonView value={object} style={darkTheme} />
106110
<JsonView value={object} style={lightTheme} />
107111
<JsonView value={object} style={nordTheme} />
108112
<JsonView value={object} style={githubLightTheme} />
109113
<JsonView value={object} style={githubDarkTheme} />
114+
<JsonView value={object} style={gruvboxTheme} />
110115
<JsonView value={object} style={vscodeTheme} />
111116
</div>
112117
);

core/gruvbox.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module '@uiw/react-json-view/gruvbox' {
2+
export const gruvboxTheme: import('react').CSSProperties;
3+
}

core/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
"types": "./cjs/theme/vscode.d.ts",
3838
"require": "./cjs/theme/vscode.js"
3939
},
40+
"./gruvbox": {
41+
"import": "./esm/theme/gruvbox.js",
42+
"types": "./cjs/theme/gruvbox.d.ts",
43+
"require": "./cjs/theme/gruvbox.js"
44+
},
4045
"./githubLight": {
4146
"import": "./esm/theme/github.light.js",
4247
"types": "./cjs/theme/github.light.d.ts",

core/src/theme/dark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ export const darkTheme = {
2121
'--w-rjv-type-date-color': '#586e75',
2222
'--w-rjv-type-url-color': '#649bd8',
2323
'--w-rjv-type-null-color': '#d33682',
24-
'--w-rjv-type-nan-color': '#859900',
24+
'--w-rjv-type-nan-color': '#076678',
2525
'--w-rjv-type-undefined-color': '#586e75',
2626
} as React.CSSProperties;

core/src/theme/github.dark.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export const githubDarkTheme = {
22
'--w-rjv-font-family': 'monospace',
33
'--w-rjv-color': '#79c0ff',
44
'--w-rjv-background-color': '#0d1117',
5-
'--w-rjv-line-color': '#36334280',
5+
'--w-rjv-line-color': '#94949480',
66
'--w-rjv-arrow-color': '#ccc',
77
'--w-rjv-edit-color': 'var(--w-rjv-color)',
88
'--w-rjv-info-color': '#7b7b7b',

core/src/theme/gruvbox.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { gruvboxTheme } from './gruvbox';
2+
3+
it('gruvboxTheme test case', () => {
4+
expect(gruvboxTheme).toHaveProperty('--w-rjv-font-family', 'monospace');
5+
expect(Object.keys(gruvboxTheme)).toMatchObject([
6+
'--w-rjv-font-family',
7+
'--w-rjv-color',
8+
'--w-rjv-background-color',
9+
'--w-rjv-line-color',
10+
'--w-rjv-arrow-color',
11+
'--w-rjv-edit-color',
12+
'--w-rjv-info-color',
13+
'--w-rjv-update-color',
14+
'--w-rjv-copied-color',
15+
'--w-rjv-copied-success-color',
16+
'--w-rjv-curlybraces-color',
17+
'--w-rjv-colon-color',
18+
'--w-rjv-brackets-color',
19+
'--w-rjv-type-string-color',
20+
'--w-rjv-type-int-color',
21+
'--w-rjv-type-float-color',
22+
'--w-rjv-type-bigint-color',
23+
'--w-rjv-type-boolean-color',
24+
'--w-rjv-type-date-color',
25+
'--w-rjv-type-url-color',
26+
'--w-rjv-type-null-color',
27+
'--w-rjv-type-nan-color',
28+
'--w-rjv-type-undefined-color',
29+
]);
30+
});

core/src/theme/gruvbox.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export const gruvboxTheme = {
2+
'--w-rjv-font-family': 'monospace',
3+
'--w-rjv-color': '#3c3836',
4+
'--w-rjv-background-color': '#fbf1c7',
5+
'--w-rjv-line-color': '#ebdbb2',
6+
'--w-rjv-arrow-color': 'var(--w-rjv-color)',
7+
'--w-rjv-edit-color': 'var(--w-rjv-color)',
8+
'--w-rjv-info-color': '#0000004d',
9+
'--w-rjv-update-color': '#ebcb8b',
10+
'--w-rjv-copied-color': '#002b36',
11+
'--w-rjv-copied-success-color': '#28a745',
12+
13+
'--w-rjv-curlybraces-color': '#236a7c',
14+
'--w-rjv-colon-color': '#002b36',
15+
'--w-rjv-brackets-color': '#236a7c',
16+
17+
'--w-rjv-type-string-color': '#3c3836',
18+
'--w-rjv-type-int-color': '#8f3f71',
19+
'--w-rjv-type-float-color': '#8f3f71',
20+
'--w-rjv-type-bigint-color': '#8f3f71',
21+
'--w-rjv-type-boolean-color': '#8f3f71',
22+
'--w-rjv-type-date-color': '#076678',
23+
'--w-rjv-type-url-color': '#0969da',
24+
'--w-rjv-type-null-color': '#076678',
25+
'--w-rjv-type-nan-color': '#076678',
26+
'--w-rjv-type-undefined-color': '#076678',
27+
} as React.CSSProperties;

core/src/value.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ export function getValueString<T>(value: T) {
9292
if (typeof value === 'number') {
9393
type = isFloat(value) ? 'float' : 'number';
9494
content = value.toString();
95+
if (isNaN(value)) {
96+
type = 'NaN';
97+
content = 'NaN';
98+
}
9599
}
96100
if (typeof value === 'boolean') {
97101
type = 'boolean';
@@ -207,7 +211,7 @@ export function ValueView<T extends object>(props: ValueViewProps<T>) {
207211
typeView = <Fragment />;
208212
style = { fontWeight: 'bold' };
209213
}
210-
if (value === undefined) {
214+
if (value === undefined || type === 'NaN') {
211215
typeView = <Fragment />;
212216
}
213217
const isURL = value instanceof URL;

www/src/example/default.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import { nordTheme } from '@uiw/react-json-view/nord';
77
import { githubLightTheme } from '@uiw/react-json-view/githubLight';
88
import { githubDarkTheme } from '@uiw/react-json-view/githubDark';
99
import { vscodeTheme } from '@uiw/react-json-view/vscode';
10+
import { gruvboxTheme } from '@uiw/react-json-view/gruvbox';
1011

1112
export const themesData = {
13+
gruvbox: gruvboxTheme,
1214
light: lightTheme,
1315
dark: darkTheme,
1416
nord: nordTheme,

0 commit comments

Comments
 (0)