Skip to content

Commit 167c357

Browse files
authored
Merge branch 'staging' into mixpanel
2 parents ef4f198 + ee58233 commit 167c357

File tree

13 files changed

+245
-18
lines changed

13 files changed

+245
-18
lines changed

package-lock.json

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

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,13 @@
118118
"rc-tooltip": "^3.7.3",
119119
"react": "^16.13.1",
120120
"react-dom": "^16.13.1",
121+
"react-google-chart": "^0.1.2",
122+
"react-google-charts": "^3.0.15",
121123
"react-html-parser": "^2.0.2",
122124
"react-json-tree": "^0.11.2",
123125
"react-router-dom": "^5.2.0",
124126
"react-select": "^3.1.0",
125-
"recoil": "0.0.10"
127+
"recoil": "0.0.10",
128+
"sankey": "^2.0.2"
126129
}
127130
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React, { Component, useEffect, useState } from 'react';
2+
// import * as d3 from 'd3';
3+
// import {sankey} from 'sankey';
4+
import { Chart } from 'react-google-charts';
5+
6+
/**
7+
* @method maked3Tree :Creates a new D3 Tree
8+
*/
9+
10+
function AtomsRelationship(props) {
11+
console.log('Props', props.atomsRel);
12+
13+
const {atomsRel} = props
14+
15+
16+
return (
17+
<div className="history-d3-container">
18+
{atomsRel && (
19+
<Chart
20+
width={'100%'}
21+
height={'100%'}
22+
chartType="Sankey"
23+
options={{
24+
sankey: {
25+
link: { color: { fill: '#gray', fillOpacity: 0.1 } },
26+
node: {
27+
colors: [
28+
'#4a91c7',
29+
'#5b9bce',
30+
'#6ba6d5',
31+
'#7bb0dc',
32+
'#8abbe3',
33+
'#99c6ea',
34+
'#a8d0f1',
35+
'#b7dbf8',
36+
'#c6e6ff',
37+
'#46edf2',
38+
'#76f5f3',
39+
'#95B6B7',
40+
'#76dcde',
41+
'#5fdaed',
42+
],
43+
44+
label: { color: '#fff', fontSize: '14' },
45+
nodePadding: 50,
46+
width: 15,
47+
},
48+
},
49+
tooltip: { textStyle: { color: 'gray', fontSize: 12 }},
50+
}}
51+
loader={<div>Loading Chart</div>}
52+
data={[['Atom', 'Selector', ''], ...atomsRel]}
53+
rootProps={{ 'data-testid': '1' }}
54+
/>)}
55+
</div>
56+
);
57+
}
58+
59+
export default AtomsRelationship;

src/app/components/ComponentMap.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ const ComponentMap = (props: componentMapProps) => {
145145

146146
//TODO -> Alter incoming snapshots so there is useful data to show on hover.
147147
nodeEnter.on('mouseover', function (d: any, i: number): any {
148-
if (!d.children) {
149-
console.log(d);
150-
console.log(d.data);
148+
151149
d3.select(this)
152150
.append('text')
153151
.text(() => {
@@ -160,7 +158,7 @@ const ComponentMap = (props: componentMapProps) => {
160158
.attr('stroke', 'white')
161159
.attr('stroke-width', .5)
162160
.attr('id', `popup${i}`);
163-
}
161+
164162
});
165163
nodeEnter.on('mouseout', function (d: any, i: number): any {
166164
d3.select(`#popup${i}`).remove();

src/app/components/History.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ const filterHooks = (data: any[]) => {
3030
return JSON.stringify(data[0].state);
3131
};
3232

33-
interface HistoryProps {
34-
hierarchy: Record<string, unknown>;
35-
}
36-
3733

3834
/**
3935
* @method maked3Tree :Creates a new D3 Tree
@@ -44,7 +40,6 @@ function History(props) {
4440
let root = JSON.parse(JSON.stringify(hierarchy));
4541
let isRecoil = false;
4642
let HistoryRef = React.createRef(root); //React.createRef(root);
47-
4843
useEffect(() => {
4944
maked3Tree();
5045
}, [root]);

src/app/components/StateRoute.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import Tree from './Tree';
1515
import ComponentMap from './ComponentMap';
1616
import PerfView from './PerfView';
17+
import AtomsRelationship from './AtomsRelationship.jsx';
1718

1819
const History = require('./History').default;
1920

@@ -29,15 +30,22 @@ interface StateRouteProps {
2930
state?: string | object;
3031
stateSnaphot?: object;
3132
children?: any[];
33+
AtomsRelationship?: any[];
3234
};
33-
hierarchy: object;
35+
hierarchy: any;
3436
snapshots: [];
3537
viewIndex: number;
3638
}
3739

3840
const StateRoute = (props: StateRouteProps) => {
3941
const { snapshot, hierarchy, snapshots, viewIndex } = props;
42+
// let isRecoil = true;
43+
// console.log('snapshot', snapshot)
44+
// console.log(snapshot.AtomsRelationship)
45+
let isRecoil = snapshot.AtomsRelationship ? true : false;
4046
const [noRenderData, setNoRenderData] = useState(false);
47+
48+
// component map zoom state
4149
const [{ x, y, k }, setZoomState]: any = useState({
4250
x: 150,
4351
y: 250,
@@ -52,14 +60,20 @@ const StateRoute = (props: StateRouteProps) => {
5260
return <div className="noState">{NO_STATE_MSG}</div>;
5361
};
5462

63+
5564
// the hierarchy gets set on the first click in the page
5665
// when the page is refreshed we may not have a hierarchy, so we need to check if hierarchy was initialized
5766
// if true involk render chart with hierarchy
5867
const renderHistory = () => {
59-
if (hierarchy) {
68+
if (hierarchy.children.length > 0) {
69+
6070
return <History hierarchy={hierarchy} />;
6171
}
62-
return <div className="noState">{NO_STATE_MSG}</div>;
72+
return <div className="noState">Application not compatible with history</div>;
73+
};
74+
75+
const renderAtomsRelationship = () => {
76+
return <AtomsRelationship atomsRel={snapshot.AtomsRelationship} />;
6377
};
6478

6579
// the hierarchy gets set on the first click in the page
@@ -119,6 +133,11 @@ const StateRoute = (props: StateRouteProps) => {
119133
<NavLink className="router-link" activeClassName="is-active" to="/map">
120134
Map
121135
</NavLink>
136+
137+
{isRecoil && <NavLink className="router-link" activeClassName="is-active" to="/relationship">
138+
Atoms Relationship
139+
</NavLink>}
140+
122141
<NavLink
123142
className="router-link"
124143
activeClassName="is-active"
@@ -130,6 +149,7 @@ const StateRoute = (props: StateRouteProps) => {
130149
<Switch>
131150
<Route path="/map" render={renderComponentMap} />
132151
<Route path="/history" render={renderHistory} />
152+
<Route path="/relationship" render={renderAtomsRelationship} />
133153
<Route path="/performance" render={renderPerfView} />
134154
<Route path="/" render={renderTree} />
135155
</Switch>

src/app/containers/StateContainer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ import DiffRoute from '../components/DiffRoute';
1212
interface StateContainerProps {
1313
snapshot: Record<number,
1414
{ name?: string; componentData?: Record<string, unknown>;
15-
state?: Record<string, unknown>; stateSnaphot?: Record<string, unknown>; children?: unknown[]; }
15+
state?: Record<string, unknown>; stateSnaphot?: Record<string, unknown>; children?: unknown[];
16+
AtomsRelationship?: any[]
17+
}
1618
> ;
19+
AtomsRelationship?: any[];
1720
hierarchy:Record<string, unknown>;
1821
snapshots:[];
1922
viewIndex:number;

src/app/styles/layout/_bodyContainer.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.body-container {
22
height: 94%;
3+
overflow: hidden;
34
display: grid;
45
grid-template-columns: 1fr 2fr;
56
grid-template-rows: 8fr 1fr;

src/app/styles/layout/_stateContainer.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.state-container {
2-
32
font-size: 12px;
43
overflow: hidden;
54
background-color: $brand-color;

0 commit comments

Comments
 (0)