Skip to content

Commit bd42cdc

Browse files
authored
Merge branch 'staging' into styling
2 parents 8fc1700 + b0f237e commit bd42cdc

File tree

4 files changed

+62
-59
lines changed

4 files changed

+62
-59
lines changed

package-lock.json

Lines changed: 13 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"react-dom": "^16.13.1",
121121
"react-google-chart": "^0.1.2",
122122
"react-google-charts": "^3.0.15",
123+
"react-google-charts-ts": "^0.1.1",
123124
"react-html-parser": "^2.0.2",
124125
"react-json-tree": "^0.11.2",
125126
"react-router-dom": "^5.2.0",

src/app/components/AtomsRelationship.jsx

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
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-
*/
1+
import React, { Component, useEffect, useState, Fragment } from 'react';
2+
import { Chart } from 'react-google-charts'
93

104
function AtomsRelationship(props) {
11-
125
const {atomsRel} = props
136

7+
const atomsAndComp = atomsRel.filter(e => e[2] !== 'atoms and selectors').map(e => {
8+
let copy = [...e];
9+
copy[2] = 1;
10+
return [...copy]
11+
});
12+
13+
const atomsAndSelectors = atomsRel.filter(e => e[2] === 'atoms and selectors').map(e => {
14+
let copy = [...e];
15+
copy[2] = 1;
16+
return [...copy]
17+
});
18+
19+
const copyatomsRel = atomsRel.map(e => { let copy = [...e]; copy[2] = 1; return copy; });
20+
const [atoms, setAtoms] = useState([...copyatomsRel]);
21+
const [atomAndSelectorCheck, setAtomAndSelectorCheck] = useState(false);
22+
const [atomAndCompCheck, setAtomAndCompCheck] = useState(false);
23+
24+
useEffect( () => {
25+
if ((!atomAndSelectorCheck && !atomAndCompCheck) || (atomAndSelectorCheck && atomAndCompCheck)) {
26+
setAtoms(copyatomsRel);
27+
} else if (atomAndSelectorCheck) {
28+
setAtoms(atomsAndSelectors);
29+
} else {
30+
setAtoms(atomsAndComp);
31+
}
32+
}, [atomAndSelectorCheck, atomAndCompCheck, props])
33+
1434
return (
15-
<div className="history-d3-container" id="atomsContainer">
16-
{atomsRel && (
35+
<div className="history-d3-container">
36+
{atoms && (
37+
<Fragment>
1738
<Chart
1839
width={'100%'}
1940
height={'100%'}
@@ -47,9 +68,19 @@ function AtomsRelationship(props) {
4768
tooltip: { textStyle: { color: 'white', fontSize: 0.1, }},
4869
}}
4970
loader={<div>Loading Chart</div>}
50-
data={[['Atom', 'Selector', ''], ...atomsRel]}
71+
data={[['Atom', 'Selector', ''], ...atoms]}
5172
rootProps={{ 'data-testid': '1' }}
52-
/>)}
73+
/>
74+
<div>
75+
<input type="checkbox" id='atomscomps' onClick={e => setAtomAndCompCheck(atomAndCompCheck ? false: true)}/>
76+
<label htmlFor="atomscomps"> Only Show Atoms (or Selectors) and Components </label>
77+
<input type="checkbox" id='atomsselectors' onClick={e => setAtomAndSelectorCheck(atomAndSelectorCheck ? false : true)} />
78+
<label htmlFor="atomsselectors"> Only Show Atoms and Selectors </label>
79+
</div>
80+
</Fragment>
81+
)
82+
83+
}
5384
</div>
5485
);
5586
}

src/backend/linkFiber.ts

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -60,37 +60,17 @@ const circularComponentTable = new Set();
6060
let allAtomsRelationship = [];
6161

6262
function getRecoilState() : any {
63-
// get the last state snapshot
6463
const RecoilSnapshotsLength = window[`$recoilDebugStates`].length;
6564
const lastRecoilSnapshot = window[`$recoilDebugStates`][RecoilSnapshotsLength - 1];
66-
console.log(lastRecoilSnapshot);
67-
68-
// get all atom - selector pairs, and save them as nodes
69-
// in the from to weight format
7065
const nodeToNodeSubs = lastRecoilSnapshot.nodeToNodeSubscriptions;
7166
let nodeToNodeSubsKeys = lastRecoilSnapshot.nodeToNodeSubscriptions.keys();
7267
nodeToNodeSubsKeys.forEach(
7368
node => {
7469
nodeToNodeSubs.get(node).forEach(
75-
nodeSubs => allAtomsRelationship.push([node, nodeSubs, 1])
70+
nodeSubs => allAtomsRelationship.push([node, nodeSubs, 'atoms and selectors'])
7671
)
7772
}
7873
)
79-
80-
// get all atom - component pairs, and save them as nodes
81-
// in the from to weight format
82-
83-
// const nodeToCompSubs = lastRecoilSnapshot.nodeToComponentSubscriptions;
84-
// console.log(nodeToCompSubs);
85-
// let nodeToCompSubsKeys = lastRecoilSnapshot.nodeToComponentSubscriptions.keys();
86-
// nodeToCompSubsKeys.forEach(
87-
// node => {
88-
// console.log(node);
89-
// // nodeToCompSubsKeys.get(node).forEach(
90-
// // nodeSubs => allAtomsRelationship.push([node, nodeSubs, 2])
91-
// // )
92-
// }
93-
// )
9474
}
9575

9676

@@ -186,13 +166,13 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
186166
if (pointer?.memoizedState[1]?.[0].current) {
187167
let atomName = pointer.memoizedState[1]?.[0].current.keys().next().value;
188168
console.log('atom', pointer.memoizedState[1]?.[0].current.keys().next().value);
189-
allAtomsRelationship.push([atomName, elementType?.name, 1])
169+
allAtomsRelationship.push([atomName, elementType?.name, 'atoms and components'])
190170
}
191171

192172
if (pointer?.memoizedState[1]?.[0].key) {
193173
let atomName = pointer.memoizedState[1]?.[0].key;
194174
console.log('atom', pointer.memoizedState[1]?.[0].key);
195-
allAtomsRelationship.push([atomName, elementType?.name, 1])
175+
allAtomsRelationship.push([atomName, elementType?.name, 'atoms and components'])
196176
}
197177
}
198178

@@ -276,17 +256,6 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
276256
state.component
277257
);
278258
componentData.hooksIndex = hooksIndex;
279-
280-
// if (newState && newState.hooksState) {
281-
// newState.hooksState.push({ [hooksNames[i]]: state.state });
282-
// } else if (newState) {
283-
// newState.hooksState = [{ [hooksNames[i]]: state.state }];
284-
// } else {
285-
// newState = { hooksState: [] };
286-
// newState.hooksState.push({ [hooksNames[i]]: state.state });
287-
// }
288-
289-
//improves tree visualization but breaks jump
290259
if (newState && newState.hooksState) {
291260
newState.push(state.state);
292261
} else if (newState) {
@@ -399,18 +368,7 @@ export default (snap: Snapshot, mode: Mode): (() => void) => {
399368
}
400369

401370
return () => {
402-
/* const container = document.getElementById('root');
403-
if (container._internalRoot) {
404-
fiberRoot = container._internalRoot;
405-
} else {
406-
const {
407-
_reactRootContainer: { _internalRoot },
408-
_reactRootContainer,
409-
} = container;
410-
// Only assign internal root if it actually exists
411-
fiberRoot = _internalRoot || _reactRootContainer;
412-
}
413-
*/
371+
414372
const devTools = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
415373
const reactInstance = devTools ? devTools.renderers.get(1) : null;
416374
fiberRoot = devTools.getFiberRoots(1).values().next().value;

0 commit comments

Comments
 (0)