Skip to content

Commit 535ea10

Browse files
committed
wip - replacing base-16 inline styles with css/scss
1 parent 8ab6cb4 commit 535ea10

19 files changed

+1066
-632
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Change Log
22

3+
## 0.30.0 - gtk-grafana FORK
4+
Removing base-16 styles and lodash dependencies
5+
36
## 0.20.0
47

58
### Minor Changes

README.md

+2-48
Original file line numberDiff line numberDiff line change
@@ -32,65 +32,19 @@ Check out [examples](examples) directory for more details.
3232

3333
### Theming
3434

35-
This component now uses [react-base16-styling](https://github.com/reduxjs/redux-devtools/tree/main/packages/react-base16-styling) module, which allows to customize component via `theme` property, which can be the following:
36-
37-
- [base16](https://github.com/chriskempson/base16) theme data. [The example theme data can be found here](https://github.com/gaearon/redux-devtools/tree/75322b15ee7ba03fddf10ac3399881e302848874/src/react/themes).
38-
- object that contains style objects, strings (that treated as classnames) or functions. A function is used to extend its first argument `{ style, className }` and should return an object with the same structure. Other arguments depend on particular context (and should be described here). See [createStylingFromTheme.js](https://github.com/reduxjs/redux-devtools/blob/main/packages/react-json-tree/src/createStylingFromTheme.ts) for the list of styling object keys. Also, this object can extend `base16` theme via `extend` property.
39-
40-
Every theme has a light version, which is enabled with `invertTheme` prop.
41-
42-
```jsx
43-
const theme = {
44-
scheme: 'monokai',
45-
author: 'wimer hazenberg (http://www.monokai.nl)',
46-
base00: '#272822',
47-
base01: '#383830',
48-
base02: '#49483e',
49-
base03: '#75715e',
50-
base04: '#a59f85',
51-
base05: '#f8f8f2',
52-
base06: '#f5f4f1',
53-
base07: '#f9f8f5',
54-
base08: '#f92672',
55-
base09: '#fd971f',
56-
base0A: '#f4bf75',
57-
base0B: '#a6e22e',
58-
base0C: '#a1efe4',
59-
base0D: '#66d9ef',
60-
base0E: '#ae81ff',
61-
base0F: '#cc6633',
62-
};
35+
Style with CSS. @todo base styles
6336

6437
<div>
65-
<JSONTree data={data} theme={theme} invertTheme={false} />
38+
<JSONTree data={data} />
6639
</div>;
6740
```
6841
69-
#### Result (Monokai theme, dark background):
70-
71-
![](http://cl.ly/image/330o2L1J3V0h/screenshot%202015-08-26%20at%2010.48.24%20AM.png)
72-
7342
#### Advanced Customization
7443
7544
```jsx
7645
<div>
7746
<JSONTree
7847
data={data}
79-
theme={{
80-
extend: theme,
81-
// underline keys for literal values
82-
valueLabel: {
83-
textDecoration: 'underline',
84-
},
85-
// switch key for objects to uppercase when object is expanded.
86-
// `nestedNodeLabel` receives additional argument `expandable`
87-
nestedNodeLabel: ({ style }, keyPath, nodeType, expanded) => ({
88-
style: {
89-
...style,
90-
textTransform: expanded ? 'uppercase' : style.textTransform,
91-
},
92-
}),
93-
}}
9448
/>
9549
</div>
9650
```

examples/package-lock.json

+3-67
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"immutable": "^4.3.7",
2323
"react-json-tree": "file:..",
2424
"react": "^18.3.1",
25-
"react-base16-styling": "^0.10.0",
2625
"react-dom": "^18.3.1"
2726
},
2827
"devDependencies": {

examples/src/App.tsx

+5-68
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
import React from 'react';
22
import { Map } from 'immutable';
3-
import { JSONTree, StylingValue } from 'react-json-tree';
4-
5-
const getLabelStyle: StylingValue = ({ style }, nodeType, expanded) => ({
6-
style: {
7-
...style,
8-
textTransform: expanded ? 'uppercase' : style!.textTransform,
9-
},
10-
});
11-
12-
const getBoolStyle: StylingValue = ({ style }, nodeType) => ({
13-
style: {
14-
...style,
15-
border: nodeType === 'Boolean' ? '1px solid #DD3333' : style!.border,
16-
borderRadius: nodeType === 'Boolean' ? 3 : style!.borderRadius,
17-
},
18-
});
3+
import { JSONTree } from 'react-json-tree';
194

205
const getItemString = (type: string) => (
216
<span>
@@ -24,17 +9,6 @@ const getItemString = (type: string) => (
249
</span>
2510
);
2611

27-
const getValueLabelStyle: StylingValue = ({ style }, nodeType, keyPath) => ({
28-
style: {
29-
...style,
30-
color:
31-
!Number.isNaN((keyPath as unknown[])[0]) &&
32-
!(parseInt(keyPath as string, 10) % 2)
33-
? '#33F'
34-
: style!.color,
35-
},
36-
});
37-
3812
const longString =
3913
'Loremipsumdolorsitamet,consecteturadipiscingelit.Namtempusipsumutfelisdignissimauctor.Maecenasodiolectus,finibusegetultricesvel,aliquamutelit.Loremipsumdolorsitamet,consecteturadipiscingelit.Namtempusipsumutfelisdignissimauctor.Maecenasodiolectus,finibusegetultricesvel,aliquamutelit.Loremipsumdolorsitamet,consecteturadipiscingelit.Namtempusipsumutfelisdignissimauctor.Maecenasodiolectus,finibusegetultricesvel,aliquamutelit.'; // eslint-disable-line max-len
4014

@@ -104,42 +78,13 @@ const data = {
10478
longString,
10579
};
10680

107-
const theme = {
108-
scheme: 'monokai',
109-
author: 'wimer hazenberg (http://www.monokai.nl)',
110-
base00: '#272822',
111-
base01: '#383830',
112-
base02: '#49483e',
113-
base03: '#75715e',
114-
base04: '#a59f85',
115-
base05: '#f8f8f2',
116-
base06: '#f5f4f1',
117-
base07: '#f9f8f5',
118-
base08: '#f92672',
119-
base09: '#fd971f',
120-
base0A: '#f4bf75',
121-
base0B: '#a6e22e',
122-
base0C: '#a1efe4',
123-
base0D: '#66d9ef',
124-
base0E: '#ae81ff',
125-
base0F: '#cc6633',
126-
};
127-
12881
const App = () => (
12982
<div>
130-
<JSONTree data={data} theme={theme} invertTheme />
83+
<JSONTree data={data} />
13184
<br />
13285
<h3>Dark Theme</h3>
133-
<JSONTree data={data} theme={theme} invertTheme={false} />
134-
<br />
135-
<h3>Hidden Root</h3>
136-
<JSONTree data={data} theme={theme} hideRoot />
137-
<br />
138-
<h3>Base16 Greenscreen Theme</h3>
139-
<JSONTree data={data} theme="greenscreen" invertTheme={false} />
140-
<h4>Inverted Theme</h4>
141-
<JSONTree data={data} theme="greenscreen" invertTheme />
142-
<br />
86+
<JSONTree data={data} />
87+
14388
<h3>Style Customization</h3>
14489
<ul>
14590
<li>
@@ -155,12 +100,6 @@ const App = () => (
155100
<div>
156101
<JSONTree
157102
data={data}
158-
theme={{
159-
extend: theme,
160-
nestedNodeLabel: getLabelStyle,
161-
value: getBoolStyle,
162-
valueLabel: getValueLabelStyle,
163-
}}
164103
getItemString={getItemString}
165104
/>
166105
</div>
@@ -171,7 +110,6 @@ const App = () => (
171110
<div>
172111
<JSONTree
173112
data={data}
174-
theme={theme}
175113
labelRenderer={([raw]) => <span>(({raw})):</span>}
176114
valueRenderer={(raw) => (
177115
<em>
@@ -190,13 +128,12 @@ const App = () => (
190128
Sort object keys with <code>sortObjectKeys</code> prop.
191129
</p>
192130
<div>
193-
<JSONTree data={data} theme={theme} sortObjectKeys />
131+
<JSONTree data={data} sortObjectKeys />
194132
</div>
195133
<p>Collapsed root node</p>
196134
<div>
197135
<JSONTree
198136
data={data}
199-
theme={theme}
200137
shouldExpandNodeInitially={() => false}
201138
/>
202139
</div>

examples/webpack.config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as path from 'path';
22
import * as webpack from 'webpack';
33
import HtmlWebpackPlugin from 'html-webpack-plugin';
44
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
5-
import BundleAnalyzerPlugin from 'webpack-bundle-analyzer';
5+
// import BundleAnalyzerPlugin from 'webpack-bundle-analyzer';
66
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
77

88
const config: webpack.Configuration = {
@@ -13,7 +13,7 @@ const config: webpack.Configuration = {
1313
static: './dist',
1414
},
1515
plugins: [
16-
new BundleAnalyzerPlugin.BundleAnalyzerPlugin(),
16+
// new BundleAnalyzerPlugin.BundleAnalyzerPlugin(),
1717
new HtmlWebpackPlugin({
1818
template: './index.html',
1919
}),

0 commit comments

Comments
 (0)