Skip to content

Commit b941750

Browse files
committed
changed tree background theme
1 parent 2af846d commit b941750

File tree

10 files changed

+2193
-2233
lines changed

10 files changed

+2193
-2233
lines changed

package-lock.json

Lines changed: 2103 additions & 2202 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"rc-tooltip": "^3.7.3",
5151
"react": "^16.8.6",
5252
"react-dom": "^16.8.6",
53-
"react-json-view": "^1.19.1",
53+
"react-json-tree": "^0.11.2",
54+
"redux-devtools-themes": "^1.0.0",
5455
"sass": "^1.22.7"
5556
}
5657
}

src/app/containers/MainContainer.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class MainContainer extends Component {
4444

4545
emptySnapshot() {
4646
const { port } = this.state;
47-
this.setState({ snapshots: [] , snapshotIndex: 0 });
48-
port.postMessage({ action: 'emptySnap'});
47+
this.setState({ snapshots: [], snapshotIndex: 0 });
48+
port.postMessage({ action: 'emptySnap' });
4949
}
5050

5151
// change the snapshot index
@@ -88,7 +88,7 @@ class MainContainer extends Component {
8888

8989
render() {
9090
const { snapshots, snapshotIndex } = this.state;
91-
91+
9292
return (
9393
<div className="main-container">
9494
<HeadContainer />

src/app/containers/StateContainer.jsx

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,76 @@
11
import React, { Component } from 'react';
2-
import ReactJson from 'react-json-view';
2+
import JSONTree from 'react-json-tree';
3+
import * as themes from 'redux-devtools-themes';
34

4-
const JsonDisplay = (snapshot, index) => (
5-
<ReactJson
6-
key={`JsonDisplay${index}`}
7-
enableClipboard={false}
8-
theme="solarized"
9-
groupArraysAfterLength={50}
10-
src={snapshot}
11-
/>
5+
const getItemString = (type, data, itemType, itemString) => (
6+
<span>
7+
//
8+
{type}
9+
</span>
1210
);
11+
1312
class StateContainer extends Component {
1413
constructor(props) {
1514
super(props);
15+
console.log(themes);
1616
}
1717

1818
render() {
19-
let snapshotObjs = [];
2019
const { snapshot } = this.props;
21-
if (snapshot) {
22-
snapshotObjs = snapshot.map((component, index) => JsonDisplay(component, index));
23-
}
24-
return <div className="state-container">{snapshotObjs}</div>;
20+
return (
21+
<div className="state-container">
22+
{snapshot && (
23+
<JSONTree
24+
data={snapshot}
25+
theme={{ tree: () => ({ className: 'json-tree' }) }}
26+
getItemString={getItemString}
27+
/>
28+
)}
29+
</div>
30+
);
2531
}
2632
}
2733

2834
export default StateContainer;
35+
36+
// const theme = {
37+
// scheme: 'monokai',
38+
// author: 'wimer hazenberg (http://www.monokai.nl)',
39+
// base00: '#272822',
40+
// base01: '#383830',
41+
// base02: '#49483e',
42+
// base03: '#75715e',
43+
// base04: '#a59f85',
44+
// base05: '#f8f8f2',
45+
// base06: '#f5f4f1',
46+
// base07: '#f9f8f5',
47+
// base08: '#f92672',
48+
// base09: '#fd971f',
49+
// base0A: '#f4bf75',
50+
// base0B: '#a6e22e',
51+
// base0C: '#a1efe4',
52+
// base0D: '#66d9ef',
53+
// base0E: '#ae81ff',
54+
// base0F: '#cc6633',
55+
// };
56+
57+
// const theme = {
58+
// scheme: 'nicinabox',
59+
// author: 'nicinabox (http://github.com/nicinabox)',
60+
// base00: '#2A2F3A',
61+
// base01: '#3C444F',
62+
// base02: '#4F5A65',
63+
// base03: '#BEBEBE',
64+
// base04: '#b0b0b0', // based on ocean theme
65+
// base05: '#d0d0d0', // based on ocean theme
66+
// base06: '#FFFFFF',
67+
// base07: '#f5f5f5', // based on ocean theme
68+
// base08: '#fb9fb1', // based on ocean theme
69+
// base09: '#FC6D24',
70+
// base0A: '#ddb26f', // based on ocean theme
71+
// base0B: '#A1C659',
72+
// base0C: '#12cfc0', // based on ocean theme
73+
// base0D: '#6FB3D2',
74+
// base0E: '#D381C3',
75+
// base0F: '#deaf8f', // based on ocean theme
76+
// };
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.json-tree {
2+
margin: 0;
3+
padding: 10px;
4+
background-color: $brand-color;
5+
list-style: none;
6+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.state-container {
2+
font-size: 15px;
3+
flex: 6 auto;
4+
height: 100%;
5+
overflow: scroll;
6+
background-color: $brand-color;
7+
}
8+
9+
// .state-container ul {
10+
// background-color: $brand-color;
11+
// }

src/app/styles/main.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
@import 'base/base', 'base/fonts', 'base/helpers', 'base/typography';
88

99
// 4. Layout-related sections
10-
@import 'layout/actionContainer';
10+
@import 'layout/actionContainer', 'layout/stateContainer';
1111

1212
// 5. Components
13-
@import 'components/buttons', 'components/actionComponent';
13+
@import 'components/buttons', 'components/actionComponent',
14+
'components/jsonTree';
1415

1516
// other styles that needs to be modularized
1617
@import 'styles';

src/app/styles/styles.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616
flex-wrap: wrap;
1717
}
1818

19-
.state-container {
20-
font-size: 15px;
21-
flex: 6 auto;
22-
height: 100%;
23-
overflow: scroll;
24-
background-color: $brand-color;
25-
}
26-
2719
/* if extension width is less than 500px, stack the body containers */
2820
// this is not working for some reason
2921
@media (max-width: 500px) {

src/extension/background.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ let snapshotArr = [];
88
// establishing connection with devtools
99
chrome.runtime.onConnect.addListener((port) => {
1010
bg = port;
11-
// bg.postMessage({ from: 'background.js', message: 'established connection', date: Date.now() });
1211

1312
// if snapshots were saved in the snapshotArr,
1413
// send it to devtools as soon as connection to devtools is made
@@ -19,7 +18,7 @@ chrome.runtime.onConnect.addListener((port) => {
1918
// receive snapshot from devtools and send it to contentScript
2019
port.onMessage.addListener((msg) => {
2120
console.log('background -> contentScript', msg);
22-
if(msg.action==='emptySnap') {
21+
if (msg.action === 'emptySnap') {
2322
snapshotArr = [];
2423
} else {
2524
// find active tab
@@ -33,6 +32,7 @@ chrome.runtime.onConnect.addListener((port) => {
3332

3433
// background.js recieves message from contentScript.js
3534
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
35+
console.log(request);
3636
// if port is not null, send a message to devtools
3737
if (bg) {
3838
// get active tab id

src/extension/contentScript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ console.log('contentScript running');
33
// listening for messages from npm package
44
window.addEventListener('message', (msg) => {
55
const { action, payload } = msg.data;
6-
6+
console.log(msg.data);
77
if (action === 'recordSnap') chrome.runtime.sendMessage(payload);
88
});
99

0 commit comments

Comments
 (0)