@@ -4,28 +4,44 @@ import { Cluster, hierarchy } from '@visx/hierarchy';
44//import { HierarchyPointNode, HierarchyPointLink } from '@visx/hierarchy/lib/types';
55import { LinkVertical } from '@visx/shape' ;
66import { LinearGradient } from '@visx/gradient' ;
7+ import { StateRouteProps } from './StateRoute'
78
89const blue = '#acdbdf' ;
9- const white = '#f0ece2' ;
10+ const selectWhite = '#f0ece2' ;
1011
1112export const lightgreen = '#0BAB64' ;
1213const green = '#3BB78F'
13- const selectOrange = '#F39F86 ' ;
14+ const orange = '#FED8B1 ' ;
1415
1516const merlinsbeard = '#f7f7f3' ;
1617export const background = '#242529' ;
1718const root = '#d2f5e3' ;
1819
19- // interface NodeShape {
20- // name: string;
21- // children?: NodeShape[];
22- //
20+ interface clusterShape {
21+ name ?: string ;
22+ children ?: clusterShape [ ]
23+ }
2324
24- const clusterData = { } ;
25- const selectorsCache = { }
25+ interface outerObjShape {
26+ name ?:string ;
27+ children ?: outerObjShape [ ]
28+ }
29+
30+ interface innerObjShape {
31+ name ?:string ;
32+ children ?: innerObjShape [ ]
33+ }
34+
35+ interface selectorsCache {
36+ [ key :string ] : any
37+ }
38+
39+
40+ const clusterData : clusterShape = { } ;
41+ const selectorsCache :selectorsCache = { }
2642
2743let initialFire = false
28- function clusterDataPopulate ( props ) {
44+ function clusterDataPopulate ( props : StateRouteProps ) {
2945 let atomCompObj = reorganizedCompObj ( props ) ;
3046
3147 //this is to set the root name property
@@ -38,15 +54,15 @@ function clusterDataPopulate(props) {
3854 if ( ! clusterData . children ) clusterData . children = [ ]
3955
4056 for ( let key in props [ 0 ] . atomSelectors ) {
41- let outerobj = { }
57+ let outerobj : outerObjShape = { }
4258 outerobj . name = key
4359 selectorsCache [ key ] = true
4460
4561 if ( props [ 0 ] . atomSelectors [ key ] . length ) {
4662 for ( let i = 0 ; i < props [ 0 ] . atomSelectors [ key ] . length ; i ++ ) {
4763
4864 if ( ! outerobj . children ) outerobj . children = [ ]
49- let innerobj = { }
65+ let innerobj : innerObjShape = { }
5066 innerobj . name = props [ 0 ] . atomSelectors [ key ] [ i ]
5167 selectorsCache [ props [ 0 ] . atomSelectors [ key ] [ i ] ] = true
5268
@@ -73,7 +89,7 @@ function clusterDataPopulate(props) {
7389 }
7490
7591 for ( let key in atomCompObj ) {
76- let outObj = { } ;
92+ let outObj : outerObjShape = { } ;
7793 if ( ! selectorsCache [ key ] ) {
7894 outObj . name = key
7995 for ( let i = 0 ; i < atomCompObj [ key ] . length ; i ++ ) {
@@ -84,8 +100,11 @@ function clusterDataPopulate(props) {
84100 }
85101 }
86102 initialFire = true
103+
87104}
88105
106+
107+
89108function reorganizedCompObj ( props ) {
90109 let atomsComponentObj = props [ 0 ] . atomsComponents ;
91110 let reorganizedCompObj = { } ;
@@ -115,8 +134,8 @@ function Node({ node }) {
115134 { node . depth !== 0 && (
116135 < circle
117136 r = { 12 }
118- fill = { isParent ? white : blue }
119- stroke = { isParent ? white : blue }
137+ fill = { isParent ? orange : blue }
138+ stroke = { isParent ? orange : blue }
120139 // onClick={() => {
121140 // alert(`clicked: ${JSON.stringify(node.data.name)}`);
122141 // }}
@@ -129,7 +148,7 @@ function Node({ node }) {
129148 textAnchor = "middle"
130149 y = "-20"
131150 style = { { pointerEvents : 'none' } }
132- fill = { isParent ? white : blue }
151+ fill = { isParent ? orange : blue }
133152 >
134153 { node . data . name }
135154 </ text >
@@ -178,8 +197,8 @@ function SelectorNode({ node }) {
178197 { node . depth !== 0 && (
179198 < circle
180199 r = { 12 }
181- fill = { selectOrange }
182- stroke = { selectOrange }
200+ fill = { selectWhite }
201+ stroke = { selectWhite }
183202 // onClick={() => {
184203 // alert(`clicked: ${JSON.stringify(node.data.name)}`);
185204 // }}
@@ -192,7 +211,7 @@ function SelectorNode({ node }) {
192211 textAnchor = "middle"
193212 y = "-20"
194213 style = { { pointerEvents : 'none' } }
195- fill = { orange }
214+ fill = { selectWhite }
196215 >
197216 { node . data . name }
198217 </ text >
0 commit comments