Skip to content

Commit c5c5d2c

Browse files
Nian LiuNian Liu
authored andcommitted
changes
1 parent 2c99f0c commit c5c5d2c

File tree

5 files changed

+117
-70
lines changed

5 files changed

+117
-70
lines changed

build/webpack-bundle.js

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

build/webpack-bundle.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/app.css

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,69 @@ body{
88
background: linear-gradient(to right, #eef2f3, #8e9eab); W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+; */
99
}
1010

11+
@media screen and (max-width: 600px) {
12+
.reactTab {
13+
display: grid;
14+
grid-template-rows: 1fr 1fr 1fr;
15+
grid-template-columns: 1fr;
16+
grid-template-areas:
17+
'sp-box'
18+
'diff'
19+
'tree';
20+
}
21+
.state-prop-display {
22+
grid-area: sp-box;
23+
background-color: #333;
24+
color: white;
25+
overflow-y: scroll;
26+
border: 1px solid black;
27+
border-radius: 5px;
28+
padding: 5px 5px;
29+
margin-right: 10px;
30+
}
31+
32+
#treeWrapper{
33+
grid-area: tree;
34+
background-color: rgba(214, 214, 214, 0.4);
35+
border: 1px solid rgba(0, 0, 0, 0.3);
36+
border-radius: 5px;
37+
padding: 10px;
38+
margin-left: 10px;
39+
}
40+
41+
#stateDiff-container {
42+
grid-area: diff;
43+
overflow-y: scroll;
44+
background-color: rgba(214, 214, 214, 0.4);
45+
border: 1px solid rgba(0, 0, 0, 0.3);
46+
border-radius: 5px;
47+
padding: 10px;
48+
margin-top: 10px;
49+
margin-right: 10px;
50+
}
51+
52+
#state-header{
53+
display: flex;
54+
/* justify-content: space-between; */
55+
margin-bottom: 5px;
56+
}
57+
58+
.stateDiff-div {
59+
overflow-x: scroll;
60+
padding: 15px;
61+
background:rgba(255,255,255,0.5);
62+
margin: 8px 0px;
63+
}
64+
65+
.state-span{
66+
margin: 6px;
67+
font-size: 1.2em;
68+
font-weight: 500;
69+
letter-spacing: 0.8px;
70+
line-height: 15px;
71+
}
72+
}
73+
1174
#app-container{
1275
display: flex;
1376
padding: 10px 25px;

src/components/TreeDiagram.jsx

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@ class TreeDiagram extends React.Component {
99
this.state = {
1010
transition: null,
1111
orientation: 'vertical',
12-
<<<<<<< HEAD
13-
foreignObjectWrapper: {x: 10, y: 4},
14-
nodeSize: {x: 85, y: 85},
15-
=======
16-
foreignObjectWrapper: {y: -5, x: 10},
17-
nodeSize: {x: 75, y: 75},
18-
>>>>>>> 9609025ded6a6f44d16730207d255bd1cb9c8d90
12+
foreignObjectWrapper: {x: 8, y: 4},
13+
nodeSize: {x: 95, y: 85},
1914
};
2015
this.handleFlip = this.handleFlip.bind(this);
2116
}
@@ -33,17 +28,13 @@ class TreeDiagram extends React.Component {
3328
});
3429
}
3530

36-
<<<<<<< HEAD
37-
38-
=======
39-
>>>>>>> 9609025ded6a6f44d16730207d255bd1cb9c8d90
4031
handleFlip() {
4132
const dimensions = this.treeContainer.getBoundingClientRect();
4233
if(this.state.orientation === 'vertical') {
4334
this.setState({
4435
orientation: 'horizontal',
4536
foreignObjectWrapper: {x: 5, y: 8},
46-
nodeSize: {x: 120, y:120},
37+
nodeSize: {x: 110, y:110},
4738
translate: {
4839
x: dimensions.width / 8,
4940
y: dimensions.height / 2
@@ -52,7 +43,7 @@ class TreeDiagram extends React.Component {
5243
} else {
5344
this.setState({
5445
orientation: 'vertical',
55-
foreignObjectWrapper: {x: 10, y: 4},
46+
foreignObjectWrapper: {x: 8, y: 4},
5647
nodeSize: {x: 85, y: 85},
5748
translate: {
5849
x: dimensions.width / 2,
@@ -69,30 +60,29 @@ class TreeDiagram extends React.Component {
6960
circle: {
7061
fill: "black",
7162
fontSize: "0.1",
72-
strokeWidth: 2
63+
strokeWidth: 0.5
7364
}
7465
},
7566
attributes: {
7667
fill: "white",
7768
fontSize: "10",
78-
strokeWidth: 1
69+
strokeWidth: 0.5
7970
},
8071
leafNode: {
8172
circle: {
8273
fill: "none",
8374
fontSize: "0.1",
84-
strokeWidth: 2
75+
strokeWidth: 0.5
8576
},
8677
attributes: {
8778
fill: "white",
8879
fontSize: "10",
89-
strokeWidth: 1
80+
strokeWidth: 0.5
9081
}
9182
}
9283
}
9384
};
9485

95-
<<<<<<< HEAD
9686

9787
return (
9888
<div id="treeWrapper" ref={tc => (this.treeContainer = tc)}>
@@ -105,20 +95,6 @@ class TreeDiagram extends React.Component {
10595
<Tree
10696
data={this.props.appState}
10797
nodeSize={this.state.nodeSize}
108-
=======
109-
return (
110-
<div id="treeWrapper" ref={tc => (this.treeContainer = tc)}>
111-
<button onClick={() => {this.handleFlip()}}> {this.state.orientation[0].toUpperCase() + this.state.orientation.slice(1)} </button>
112-
<button onClick={() => { this.props.handleFilter(filterComponents.reduxComponents) }}>Filter Redux</button>
113-
<button onClick={() => { this.props.handleFilter(filterComponents.reactRouterComponents) }}>Filter React-Router</button>
114-
<button onClick={() => { this.props.handleFilter(filterComponents.apolloComponents) }}>Filter Apollo-GraphQL</button>
115-
116-
{/* when appState has a length we populate tree */}
117-
{this.props.appState.length !== 0 ? (
118-
<Tree
119-
data={this.props.appState}
120-
nodeSize={{ x: 75, y: 75 }}
121-
>>>>>>> 9609025ded6a6f44d16730207d255bd1cb9c8d90
12298
orientation={this.state.orientation}
12399
styles={styles}
124100
translate={this.state.translate}

src/devtools.js

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ class App extends Component {
2626
componentsToFilter: [],
2727
};
2828

29-
this.handleMouseOver = this.handleMouseOver.bind(this);
30-
3129
chrome.devtools.panels.create("Lucid", null, "devtools.html");
3230
}
3331

@@ -107,39 +105,6 @@ class App extends Component {
107105
);
108106
}
109107
}
110-
111-
handleFilter(e, arr) {
112-
//* if first index of arr is not in componentsToFilter arr, set incoming array to componentsToFilter
113-
if(e.target.classList.contains('toggleOn')) {
114-
e.target.classList.remove('toggleOn')
115-
} else {
116-
e.target.classList.add('toggleOn');
117-
}
118-
let result = [];
119-
if(!this.state.componentsToFilter.includes(arr[0])) {
120-
let componentsArr = this.state.componentsToFilter.concat(arr);
121-
filter(this.state.appState, componentsArr, result);
122-
this.setState({
123-
componentsToFilter: componentsArr,
124-
filteredData: result
125-
});
126-
}
127-
else {
128-
//* if componentsToFilter is not empty iterate through
129-
let list = this.state.componentsToFilter;
130-
for (let i = 0; i < list.length; i++) {
131-
if (arr.includes(list[i])) {
132-
// output.push(list[i]);
133-
list.splice(i--, 1);
134-
}
135-
}
136-
filter(this.state.appState, list, result);
137-
this.setState({
138-
componentsToFilter: list,
139-
filteredData: result
140-
});
141-
}
142-
}
143108

144109
//* invoke schema fetch only after a log object from a previous response is available
145110
componentDidUpdate(prevProps, prevState) {
@@ -158,7 +123,6 @@ class App extends Component {
158123
}
159124
}
160125

161-
162126
// * Handles the tab click for tree and req/res window
163127
handleWindowChange(target) {
164128
console.log(target);
@@ -174,7 +138,12 @@ class App extends Component {
174138
}
175139

176140
// * Handles the filter for the component tree
177-
handleFilter(arr) {
141+
handleFilter(e, arr) {
142+
if(e.target.classList.contains('toggleOn')) {
143+
e.target.classList.remove('toggleOn')
144+
} else {
145+
e.target.classList.add('toggleOn');
146+
}
178147
let result = [];
179148
if (!this.state.componentsToFilter.includes(arr[0])) {
180149
let componentsArr = this.state.componentsToFilter.concat(arr);
@@ -253,7 +222,7 @@ class App extends Component {
253222
) : (
254223
<div class='reactTab'>
255224
<StateContainer clearLog={this.handleClearLog.bind(this)} stateDiffs={this.state.stateDiff} />
256-
<TreeDiagram appState={this.state.appFilteredDOM.length === 0 ? this.state.appState : this.state.appFilteredDOM} handleMouseOver={this.handleMouseOver} handleFilter={this.handleFilter.bind(this)} />
225+
<TreeDiagram appState={this.state.appFilteredDOM.length === 0 ? this.state.appState : this.state.appFilteredDOM} handleMouseOver={this.handleMouseOver.bind(this)} handleFilter={this.handleFilter.bind(this)} />
257226
<StatePropsBox nodeData={this.state.nodeData} />
258227
</div>
259228
)}

0 commit comments

Comments
 (0)