Skip to content

Commit 45ddca9

Browse files
committed
(add) Finished algorithm logic that now successfully renders selectors to atoms to components relationships
1 parent 43d202e commit 45ddca9

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/app/components/AtomsRelationship.jsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const root = '#d2f5e3';
2121
//
2222

2323
const clusterData = {};
24-
let memoizeObjSelectors = {};
25-
24+
25+
let isFired = false
2626
function clusterDataPopulate(props) {
2727
let atomCompObj = reorganizedCompObj(props);
2828
console.log(props)
@@ -36,12 +36,14 @@ function clusterDataPopulate(props) {
3636
//we'll first handle AtomSelectors
3737
if(Object.entries(props[0].atomSelectors).length !== 0){
3838
if(!clusterData.children) clusterData.children = []
39+
3940
for(let key in props[0].atomSelectors){
4041
let outerobj = {}
4142
outerobj.name = key
4243

4344
if(props[0].atomSelectors[key].length){
4445
for(let i=0; i<props[0].atomSelectors[key].length;i++){
46+
4547
if(!outerobj.children) outerobj.children = []
4648
let innerobj = {}
4749
innerobj.name = props[0].atomSelectors[key][i]
@@ -53,20 +55,22 @@ function clusterDataPopulate(props) {
5355
innerobj.children.push({name:atomCompObj[props[0].atomSelectors[key][i]]})
5456
}
5557
}
56-
5758
outerobj.children.push(innerobj)
58-
//selector to component directly
59-
if(atomCompObj[key]){
60-
outerobj.children.push({name:key})
61-
}
62-
63-
6459
}
6560
}
6661

62+
// selector to component directly
63+
if(atomCompObj[key] && atomCompObj[key].length){
64+
for (let i=0; i<atomCompObj[key].length;i++){
65+
outerobj.children.push({name:atomCompObj[key][i]})
66+
}
67+
}
68+
69+
clusterData.children.push(outerobj)
6770
}
6871
}
69-
72+
console.log(clusterData)
73+
isFired = true
7074
}
7175

7276
function reorganizedCompObj(props) {
@@ -166,8 +170,11 @@ export default function Example({
166170
margin = defaultMargin,
167171
snapshots,
168172
}) {
169-
clusterDataPopulate(snapshots);
170173

174+
if(!isFired){
175+
clusterDataPopulate(snapshots);
176+
}
177+
171178
const data = useMemo(() => hierarchy(clusterData), []);
172179
const xMax = width - margin.left - margin.right;
173180
const yMax = height - margin.top - margin.bottom;

0 commit comments

Comments
 (0)