You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/app/components/StateRoute/ComponentMap/ComponentMap.tsx
+14-12Lines changed: 14 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,7 @@ export default function ComponentMap({
58
58
letsizeHeight: number;
59
59
60
60
/*
61
-
This sets the starting position for the root node on the maps display.
61
+
We begin setting the starting position for the root node on the maps display.
62
62
The 'polar layout' sets the root node to the relative center of the display box based on the size of the browser window.
63
63
The 'cartesian layout' (else conditional) sets the root nodes location either in the left middle *or top middle of the browser window relative to the size of the browser.
64
64
*/
@@ -84,7 +84,6 @@ export default function ComponentMap({
84
84
}
85
85
}
86
86
87
-
// Tooltip stuff that was destructured from the returned object from 'useTooltip()'
88
87
const{
89
88
tooltipData,// value/data that tooltip may need to render
90
89
tooltipLeft,// number used for tooltip positioning
@@ -128,14 +127,14 @@ export default function ComponentMap({
128
127
129
128
constnodeList: []=[];// create a nodeList array to store our nodes as a flat array
130
129
131
-
constcollectNodes: void=(node)=>{
132
-
nodeList.splice(0,nodeList.length);
133
-
nodeList.push(node);
134
-
for(leti=0;i<nodeList.length;i+=1){
130
+
constcollectNodes: void=(node)=>{// function that takes in a node (snapshot) as it's argument and modifies 'nodeList' so that the node and it's children are all within the flattened 'nodeList'.
131
+
nodeList.splice(0,nodeList.length);// deletes all the nodes in nodelist
132
+
nodeList.push(node);// pushes the snapshot into nodeList
133
+
for(leti=0;i<nodeList.length;i+=1){// iterate through the nodeList that contains our snapshot
135
134
constcur=nodeList[i];
136
-
if(cur.children&&cur.children.length>0){
137
-
for(constchildofcur.children){
138
-
nodeList.push(child);
135
+
if(cur.children&&cur.children.length>0){// if the currently itereated snapshot has non-zero children...
136
+
for(constchildofcur.children){// iterate through each child in the children array
137
+
nodeList.push(child);// add the child to the nodeList
139
138
}
140
139
}
141
140
}
@@ -155,7 +154,7 @@ export default function ComponentMap({
155
154
if(startNode===null)startNode=rootNode;
156
155
};
157
156
158
-
findSelectedNode();
157
+
findSelectedNode();// locates the rootNode... do we really need this? This function is only used once... it's here.
@@ -206,7 +205,7 @@ export default function ComponentMap({
206
205
))}
207
206
208
207
{tree.descendants().map((node,key)=>{
209
-
constwidthFunc:number=(name)=>{// function that takes in a node's name and returns a number that is related to the length of the name.
208
+
constwidthFunc:number=(name)=>{// function that takes in a node's name and returns a number that is related to the length of the name. Used for determining the node width.
210
209
constnodeLength=name.length;
211
210
if(nodeLength<=5)returnnodeLength+80;// returns a number between 80-85
212
211
if(nodeLength<=10)returnnodeLength+120;// returns a number between 125-130
@@ -260,6 +259,7 @@ export default function ComponentMap({
260
259
}}
261
260
/>
262
261
)}
262
+
263
263
{/* This creates the rectangle boxes for each component
264
264
and sets it relative position to other parent nodes of the same level. */}
265
265
{node.depth!==0&&(
@@ -271,7 +271,7 @@ export default function ComponentMap({
271
271
fill={node.children ? '#161521' : '#62d6fb'}
272
272
stroke={
273
273
node.data.isExpanded&&node.data.children.length>0
274
-
? '#F00008'// changed to #F00008 for higher contrast
274
+
? '#F00008'
275
275
: '#4D4D4D'
276
276
}
277
277
strokeWidth={1.5}
@@ -281,6 +281,7 @@ export default function ComponentMap({
281
281
dispatch(toggleExpanded(node.data));
282
282
hideTooltip();
283
283
}}
284
+
284
285
// Mouse Enter Rect (Component Node) -----------------------------------------------------------------------
285
286
/** This onMouseEnter event fires when the mouse first moves/hovers over a component node.
286
287
* The supplied event listener callback produces a Tooltip element for the current node. */
@@ -317,6 +318,7 @@ export default function ComponentMap({
317
318
}}
318
319
/>
319
320
)}
321
+
320
322
{/* Display text inside of each component node */}
Copy file name to clipboardExpand all lines: src/app/components/StateRoute/ComponentMap/LinkControls.tsx
+11-10Lines changed: 11 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -49,11 +49,9 @@ export default function LinkControls({
49
49
collectNodes(snapShots);
50
50
51
51
return(
52
-
<divstyle={controlStyles}>
53
-
{/* Controls for the layout selection */}
52
+
<divstyle={controlStyles}>{/* Controls for the layout selection */}
54
53
<label>Layout:</label>
55
-
{' '}
56
-
{/* This is a non-breaking space - Prevents an automatic line break at this position */}
54
+
{' '}{/* This is a non-breaking space - Prevents an automatic line break at this position */}
57
55
<select
58
56
onClick={(e)=>e.stopPropagation()}
59
57
onChange={(e)=>setLayout(e.target.value)}
@@ -64,8 +62,8 @@ export default function LinkControls({
64
62
<optionvalue='polar'>Polar</option>
65
63
</select>
66
64
67
-
{/* Controls for the Orientation selection, this dropdown will be disabled when the polar layout is selected as it is not needed */}
68
-
<label>Orientation:</label>
65
+
66
+
<label>Orientation:</label>{/* Controls for the Orientation selection, this dropdown will be disabled when the polar layout is selected as it is not needed */}
69
67
70
68
<select
71
69
onClick={(e)=>e.stopPropagation()}
@@ -77,8 +75,9 @@ export default function LinkControls({
77
75
<optionvalue='horizontal'>Horizontal</option>
78
76
</select>
79
77
80
-
{/* Controls for the link selections. */}
81
-
<label>Link:</label>
78
+
79
+
80
+
<label>Link:</label>{/* Controls for the link selections. */}
82
81
83
82
<select
84
83
onClick={(e)=>e.stopPropagation()}
@@ -89,8 +88,9 @@ export default function LinkControls({
89
88
<optionvalue='step'>Step</option>
90
89
<optionvalue='line'>Line</option>
91
90
</select>
92
-
{/* Controls for the select selections. */}
93
-
<label> Select:</label>
91
+
92
+
93
+
<label> Select:</label>{/* Controls for the select selections. */}
94
94
95
95
<select
96
96
id='selectInput'
@@ -107,6 +107,7 @@ export default function LinkControls({
107
107
),
108
108
)}
109
109
</select>
110
+
110
111
{/* This is the slider control for the step option */}
Copy file name to clipboardExpand all lines: src/app/components/StateRoute/ComponentMap/getLinkComponent.ts
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ import {
15
15
import{LinkComponent}from'../../../FrontendTypes'
16
16
17
17
/*
18
-
18
+
Changes the shape of the LinkComponent based on the layout, linkType, and orientation
19
19
*/
20
20
21
21
exportdefaultfunctiongetLinkComponent({
@@ -25,7 +25,7 @@ export default function getLinkComponent({
25
25
}: LinkComponent): React.ComponentType<unknown>{
26
26
letLinkComponent: React.ComponentType<unknown>;
27
27
28
-
if(layout==='polar'){
28
+
if(layout==='polar'){// if the layout is polar, linkType can be either step, curve, line, or a plain LinkRadial.
29
29
if(linkType==='step'){
30
30
LinkComponent=LinkRadialStep;
31
31
}elseif(linkType==='curve'){
@@ -35,7 +35,7 @@ export default function getLinkComponent({
35
35
}else{
36
36
LinkComponent=LinkRadial;
37
37
}
38
-
}elseif(orientation==='vertical'){
38
+
}elseif(orientation==='vertical'){// if the layout isn't polar and the orientation is vertical, linkType can be either step, curve, line, or a plain LinkVertical
39
39
if(linkType==='step'){
40
40
LinkComponent=LinkVerticalStep;
41
41
}elseif(linkType==='curve'){
@@ -45,7 +45,7 @@ export default function getLinkComponent({
45
45
}else{
46
46
LinkComponent=LinkVertical;
47
47
}
48
-
}elseif(linkType==='step'){
48
+
}elseif(linkType==='step'){// if orientation and layout still haven't matched, linkType will determine our linkComponent type based on if linkType is step, curve, line, or a plain LinkHorizontal
0 commit comments