@@ -4,11 +4,47 @@ import { LegendOrdinal, LegendItem, LegendLabel } from '@visx/legend';
4
4
5
5
// implement algorithm to check snapshot history and their respective colors
6
6
const ordinalColorScale = scaleOrdinal < number , string > ( {
7
- domain : [ 1 , 2 , 3 , 4 ] ,
7
+ domain : [ 1.0 , 2.0 , 3.0 , 4.0 , 4.1 , 4.2 , 5.0 , 5.1 , 5.2 ] ,
8
8
// sync in with the snapshot color chosen in history tab already
9
9
range : [ '#66d981' , '#71f5ef' , '#4899f1' , '#7d81f6' ] ,
10
10
} ) ;
11
11
12
+ const displayArray = ( obj : {
13
+ stateSnapshot : { children : any [ ] } ;
14
+ name : number ;
15
+ branch : number ;
16
+ index : number ;
17
+ children ?: [ ] ;
18
+ } ) => {
19
+ if (
20
+ obj . stateSnapshot . children . length > 0 &&
21
+ obj . stateSnapshot . children [ 0 ] &&
22
+ obj . stateSnapshot . children [ 0 ] . state &&
23
+ obj . stateSnapshot . children [ 0 ] . name
24
+ ) {
25
+ const newObj : Record < string , unknown > = {
26
+ index : obj . index ,
27
+ displayName : `${ obj . name } .${ obj . branch } ` ,
28
+ state : obj . stateSnapshot . children [ 0 ] . state ,
29
+ componentName : obj . stateSnapshot . children [ 0 ] . name ,
30
+ componentData :
31
+ JSON . stringify ( obj . stateSnapshot . children [ 0 ] . componentData ) === '{}'
32
+ ? ''
33
+ : obj . stateSnapshot . children [ 0 ] . componentData ,
34
+ } ;
35
+ hierarchyArr . push ( newObj ) ;
36
+ }
37
+ if ( obj . children ) {
38
+ obj . children . forEach ( ( element ) => {
39
+ displayArray ( element ) ;
40
+ } ) ;
41
+ }
42
+ } ;
43
+ // the hierarchy gets set on the first click in the page
44
+ // when page in refreshed we may not have a hierarchy so we need to check if hierarchy was initialized
45
+ // if true involk displayArray to display the hierarchy
46
+ // if (hierarchy) displayArray(hierarchy);
47
+
12
48
const legendGlyphSize = 12 ;
13
49
14
50
export default function Legendary ( { events = false } : { events ?: boolean } ) {
@@ -26,7 +62,7 @@ export default function Legendary({ events = false }: { events?: boolean }) {
26
62
if ( events ) alert ( `clicked: ${ JSON . stringify ( label ) } ` ) ;
27
63
} }
28
64
>
29
- < svg width = { legendGlyphSize } height = { legendGlyphSize } >
65
+ < svg width = { 10 } height = { 10 } >
30
66
< rect
31
67
fill = { label . value }
32
68
width = { legendGlyphSize }
@@ -48,7 +84,7 @@ export default function Legendary({ events = false }: { events?: boolean }) {
48
84
.legends {
49
85
font-family: arial;
50
86
font-weight: 900;
51
- background-color: ${ 242529 } ;
87
+ background-color: 242529;
52
88
border-radius: 14px;
53
89
padding: 24px 24px 24px 32px;
54
90
overflow-y: auto;
@@ -76,7 +112,7 @@ function LegendVisual({
76
112
.legend {
77
113
line-height: 0.9em;
78
114
color: #efefef;
79
- font-size: 10px ;
115
+ font-size: 9px ;
80
116
font-family: arial;
81
117
padding: 10px 10px;
82
118
float: left;
0 commit comments