Skip to content

Commit d8d5104

Browse files
authored
Merge pull request #36 from aquinojardim/extension
Debugged Diff and Sync Performance data
2 parents 26e2b95 + 86427bb commit d8d5104

File tree

6 files changed

+46
-21
lines changed

6 files changed

+46
-21
lines changed

src/app/components/Action.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@ const Action = props => {
2323
} else {
2424
seconds = '00';
2525
}
26-
miliseconds = JSON.stringify(miliseconds);
26+
miliseconds = Number.parseFloat(miliseconds).toFixed(2)
2727
const arrayMiliseconds = miliseconds.split('.');
2828
if (arrayMiliseconds[0].length < 2) {
2929
arrayMiliseconds[0] = '0'.concat(arrayMiliseconds[0]);
3030
}
31-
if (arrayMiliseconds[1].length > 3) {
32-
arrayMiliseconds[1] = arrayMiliseconds[1].slice(0, 2);
33-
}
3431
if (index == 0) {
3532
return `${seconds}:${arrayMiliseconds[0]}.${arrayMiliseconds[1]}`;
3633
}

src/app/components/Diff.jsx

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,46 @@ function Diff({ snapshot, show }) {
2222
previous = snapshots[sliderIndex - 1];
2323
// console.log('previous with sliderIndex - 1: ', previous)
2424
}
25-
// Nate:: diff function returns a comparaison of two objects, one has an updated change
26-
const delta = diff(previous, snapshot); // initilly an array with one object, on state change becomes an object
27-
// console.log('delta: ', delta);
28-
// returns html in string
29-
const html = formatters.html.format(delta, previous);
30-
// console.log('html -->', html)
31-
if (show){
32-
// console.log('showing unchanged values', formatters.html.showUnchanged() );
33-
formatters.html.showUnchanged();
34-
} else {
35-
// console.log('hiding unchanged values', formatters.html.hideUnchanged() );
36-
formatters.html.hideUnchanged();
25+
26+
// gabi :: cleanning preview from stateless data
27+
const statelessCleanning = obj => {
28+
const newObj = { ...obj };
29+
if (newObj.name === 'nameless') {
30+
delete newObj.name;
31+
}
32+
if (newObj.componentData) {
33+
delete newObj.componentData;
34+
}
35+
if (newObj.state === 'stateless') {
36+
delete newObj.state;
37+
}
38+
if (newObj.stateSnaphot) {
39+
newObj.stateSnaphot = statelessCleanning(obj.stateSnaphot);
40+
}
41+
if (newObj.children) {
42+
newObj.children = [];
43+
if (obj.children.length > 0) {
44+
obj.children.forEach(element => {
45+
if (element.state !== 'stateless' || element.children.length > 0) {
46+
const clean = statelessCleanning(element);
47+
newObj.children.push(clean);
48+
}
49+
});
50+
}
51+
}
52+
return newObj;
3753
};
38-
54+
// gabi :: just display stateful data
55+
const previousDisplay = statelessCleanning(previous);
56+
// Nate:: diff function returns a comparison of two objects, one has an updated change
57+
// gabi :: just display stateful data
58+
const delta = diff(previousDisplay, snapshot);
59+
// returns html in string
60+
// gabi :: just display stateful data
61+
const html = formatters.html.format(delta, previousDisplay);
62+
if (show) formatters.html.showUnchanged();
63+
else formatters.html.hideUnchanged();
64+
3965
if (previous === undefined || delta === undefined) {
4066
return <div className='noState'> No state change detected. Trigger an event to change state </div>;
4167
}

src/app/components/StateRoute.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ const StateRoute = ({ snapshot, hierarchy, snapshots, viewIndex }) => {
3939
<Router>
4040
<div className="navbar">
4141
<NavLink className="router-link" activeClassName="is-active" exact to="/">
42-
State
42+
Tree
4343
</NavLink>
4444
<NavLink className="router-link" activeClassName="is-active" to="/chart">
4545
History
4646
</NavLink>
4747
<NavLink className="router-link" activeClassName="is-active" to="/performance">
48-
Rendering
48+
Performance
4949
</NavLink>
5050
</div>
5151
<Switch>

src/app/styles/components/_actionComponent.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515

1616
.action-component-text{
17-
margin-bottom: 10px;
17+
margin-bottom: 8px;
1818
}
1919

2020
.action-component.selected {

src/app/styles/components/_buttons.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
.time-button {
2222
outline: none;
2323
height: 20px;
24+
margin-bottom: 8px;
2425
width: 70px;
2526
border: none;
2627
border-radius: 3px;
@@ -31,6 +32,7 @@
3132

3233
.jump-button {
3334
@extend %button-shared;
35+
margin-bottom: 8px;
3436
width: 50px;
3537
opacity: 0;
3638
transform: rotateX(90deg);

src/app/styles/components/d3graph.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ div.tooltip {
9696
.perfContainer {
9797
display: block;
9898
margin: 0 -14px;
99-
background-color: hsl(152,80%,80%);
99+
background-color: hsl(221,16%,20%);
100100
/* border: 2px solid red; */
101101
}
102102

0 commit comments

Comments
 (0)