Skip to content

Commit 23c2122

Browse files
committed
Merge branch 'implementAtomsMap' of https://github.com/kevinfey/reactime into implementAtomsMap
2 parents ea35c40 + 2b601df commit 23c2122

File tree

9 files changed

+53
-218
lines changed

9 files changed

+53
-218
lines changed

src/app/components/AtomsRelationship.jsx

Lines changed: 39 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -1,219 +1,57 @@
11
import React, { Component, useEffect, useState } from 'react';
22
// import * as d3 from 'd3';
33
// import {sankey} from 'sankey';
4-
import { Chart } from "react-google-charts";
5-
/**
6-
* @var colors: Colors array for the diffrerent node branches, each color is for a different branch
7-
*/
8-
const colors = [
9-
'#95B6B7',
10-
'#475485',
11-
'#519331',
12-
'#AA5039',
13-
'#8B2F5F',
14-
'#C5B738',
15-
'#858DFF',
16-
'#FF8D02',
17-
'#FFCD51',
18-
'#ACDAE6',
19-
'#FC997E',
20-
'#CF93AD',
21-
'#AA3939',
22-
'#AA6C39',
23-
'#226666',
24-
'#2C4870',
25-
];
26-
27-
// interface HistoryProps {
28-
// hierarchy: Record<string, unknown>;
29-
// }
30-
31-
const data = {
32-
nodes: [
33-
{
34-
name: 'atom 1',
35-
category: 1
36-
},
37-
{
38-
name: 'atom 2',
39-
category: 1
40-
},
41-
{
42-
name: 'atom 3',
43-
category: 1
44-
},
45-
{
46-
name: 'selector 1',
47-
category: 2
48-
},
49-
{
50-
name: 'selector 2',
51-
category: 2
52-
},
53-
{
54-
name: 'component 1',
55-
category: 3
56-
},
57-
{
58-
name: 'component 2',
59-
category: 3
60-
},
61-
{
62-
name: 'component 3',
63-
category: 3
64-
},
65-
],
66-
links: [
67-
{
68-
source: "atom 1",
69-
target: "select 1",
70-
value: 100
71-
},
72-
{
73-
source: "atom 1",
74-
target: "component 1",
75-
value: 100
76-
},
77-
{
78-
source: "atom 2",
79-
target: "component 2",
80-
value: 100
81-
},
82-
{
83-
source: "atom 2",
84-
target: "select 2",
85-
value: 100
86-
},
87-
{
88-
source: "atom 3",
89-
target: "component 3",
90-
value: 100
91-
},
92-
{
93-
source: "selector 2",
94-
target: "component 1",
95-
value: 100
96-
},
97-
{
98-
source: "selector 1",
99-
target: "component 1",
100-
value: 100
101-
},
102-
]
103-
104-
}
105-
106-
4+
import { Chart } from 'react-google-charts';
1075

1086
/**
1097
* @method maked3Tree :Creates a new D3 Tree
1108
*/
1119

11210
function AtomsRelationship(props) {
113-
// let { hierarchy } = props;
114-
// let root = JSON.parse(JSON.stringify(hierarchy));
115-
// let HistoryRef = React.createRef(root); //React.createRef(root);
11611
console.log('Props', props.atomsRel);
117-
useEffect(() => {
118-
maked3Tree();
119-
}, [root]);
120-
121-
let removed3Tree = function () {
122-
const { current } = HistoryRef;
123-
while (current.hasChildNodes()) {
124-
current.removeChild(current.lastChild);
125-
}
126-
};
12712

128-
/**
129-
* @method maked3Tree Creates a new Tree History
130-
* @var
131-
*/
132-
let maked3Tree = function () {
133-
// removed3Tree();
134-
// const dimension = {width: 800, height: 500};
135-
// const margin = {left: 10, right: 10, top:10, bottom:10};
13+
const {atomsRel} = props
13614

137-
// const svg = d3.select(HistoryRef.current)
138-
// .append('svg')
139-
// .attr('width', dimension.width)
140-
// .attr('height', dimension.height);
141-
142-
// const graph = svg.append('g')
143-
// .attr('width', dimension.width - margin.left - margin.right)
144-
// .attr('width', dimension.height - margin.top - margin.bottom);
145-
146-
// // const sankey = d3.sankey()
147-
// // .nodeWidth(36)
148-
// // .nodePadding(290)
149-
// // .size([dimension.width, dimension.height])
150-
// console.log(data);
151-
// let a = sankey.nodes(data.nodes).links(data.links).layout(1);
152-
// console.log(a);
153-
// console.log(d3);
154-
return 2
155-
};
15615

15716
return (
15817
<div className="history-d3-container">
159-
{/* <div ref={HistoryRef} className="history-d3-div" /> */}
160-
<Chart
161-
width={600}
162-
height={'300px'}
163-
chartType="Sankey"
164-
loader={<div>Loading Chart</div>}
165-
data={[
166-
['From', 'To', 'Weight'],
167-
...props.atomsRel
168-
// ['Brazil', 'Portugal', 5],
169-
// ['Brazil', 'France', 1],
170-
// ['Brazil', 'Spain', 1],
171-
// ['Brazil', 'England', 1],
172-
// ['Canada', 'Portugal', 1],
173-
// ['Canada', 'France', 5],
174-
// ['Canada', 'England', 1],
175-
// ['Mexico', 'Portugal', 1],
176-
// ['Mexico', 'France', 1],
177-
// ['Mexico', 'Spain', 5],
178-
// ['Mexico', 'England', 1],
179-
// ['USA', 'Portugal', 1],
180-
// ['USA', 'France', 1],
181-
// ['USA', 'Spain', 1],
182-
// ['USA', 'England', 5],
183-
// ['Portugal', 'Angola', 2],
184-
// ['Portugal', 'Senegal', 1],
185-
// ['Portugal', 'Morocco', 1],
186-
// ['Portugal', 'South Africa', 3],
187-
// ['France', 'Angola', 1],
188-
// ['France', 'Senegal', 3],
189-
// ['France', 'Mali', 3],
190-
// ['France', 'Morocco', 3],
191-
// ['France', 'South Africa', 1],
192-
// ['Spain', 'Senegal', 1],
193-
// ['Spain', 'Morocco', 3],
194-
// ['Spain', 'South Africa', 1],
195-
// ['England', 'Angola', 1],
196-
// ['England', 'Senegal', 1],
197-
// ['England', 'Morocco', 2],
198-
// ['England', 'South Africa', 7],
199-
// ['South Africa', 'China', 5],
200-
// ['South Africa', 'India', 1],
201-
// ['South Africa', 'Japan', 3],
202-
// ['Angola', 'China', 5],
203-
// ['Angola', 'India', 1],
204-
// ['Angola', 'Japan', 3],
205-
// ['Senegal', 'China', 5],
206-
// ['Senegal', 'India', 1],
207-
// ['Senegal', 'Japan', 3],
208-
// ['Mali', 'China', 5],
209-
// ['Mali', 'India', 1],
210-
// ['Mali', 'Japan', 3],
211-
// ['Morocco', 'China', 5],
212-
// ['Morocco', 'India', 1],
213-
// ['Morocco', 'Japan', 3],
214-
]}
215-
rootProps={{ 'data-testid': '2' }}
216-
/>
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+
/>)}
21755
</div>
21856
);
21957
}

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: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ interface StateRouteProps {
3232
children?: any[];
3333
AtomsRelationship?: any[];
3434
};
35-
hierarchy: object;
35+
hierarchy: any;
3636
snapshots: [];
3737
viewIndex: number;
3838
}
@@ -44,6 +44,8 @@ const StateRoute = (props: StateRouteProps) => {
4444
// console.log(snapshot.AtomsRelationship)
4545
let isRecoil = snapshot.AtomsRelationship ? true : false;
4646
const [noRenderData, setNoRenderData] = useState(false);
47+
48+
// component map zoom state
4749
const [{ x, y, k }, setZoomState]: any = useState({
4850
x: 150,
4951
y: 250,
@@ -63,10 +65,11 @@ const StateRoute = (props: StateRouteProps) => {
6365
// when the page is refreshed we may not have a hierarchy, so we need to check if hierarchy was initialized
6466
// if true involk render chart with hierarchy
6567
const renderHistory = () => {
66-
if (hierarchy) {
68+
if (hierarchy.children.length > 0) {
69+
6770
return <History hierarchy={hierarchy} />;
6871
}
69-
return <div className="noState">{NO_STATE_MSG}</div>;
72+
return <div className="noState">Application not compatible with history</div>;
7073
};
7174

7275
const renderAtomsRelationship = () => {

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.state-container {
22
font-size: 12px;
3-
overflow: auto;
3+
overflow: hidden;
44

55
background-color: $brand-color;
66
}

src/backend/linkFiber.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function getRecoilState() : any {
6767
nodeToNodeSubsKeys.forEach(
6868
node => {
6969
nodeToNodeSubs.get(node).forEach(
70-
nodeSubs => allAtomsRelationship.push([node, nodeSubs, 2])
70+
nodeSubs => allAtomsRelationship.push([node, nodeSubs, 1])
7171
)
7272
}
7373
)
@@ -166,13 +166,13 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
166166
if (pointer?.memoizedState[1]?.[0].current) {
167167
let atomName = pointer.memoizedState[1]?.[0].current.keys().next().value;
168168
console.log('atom', pointer.memoizedState[1]?.[0].current.keys().next().value);
169-
allAtomsRelationship.push([atomName, elementType?.name, 2])
169+
allAtomsRelationship.push([atomName, elementType?.name, 1])
170170
}
171171

172172
if (pointer?.memoizedState[1]?.[0].key) {
173173
let atomName = pointer.memoizedState[1]?.[0].key;
174174
console.log('atom', pointer.memoizedState[1]?.[0].key);
175-
allAtomsRelationship.push([atomName, elementType?.name, 2])
175+
allAtomsRelationship.push([atomName, elementType?.name, 1])
176176
}
177177
}
178178

src/extension/build/assets/logo.png

-36.2 KB
Loading

src/extension/build/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Reactime",
3-
"version": "4.0.2",
3+
"version": "5.0.0",
44
"devtools_page": "devtools.html",
55
"description": "A Chrome extension that helps debug React applications by memorizing the state of components with every render.",
66
"manifest_version": 2,

0 commit comments

Comments
 (0)