@@ -25,8 +25,7 @@ import WebMetrics from './WebMetrics';
25
25
const History = require ( './History' ) . default ;
26
26
const ErrorHandler = require ( './ErrorHandler' ) . default ;
27
27
28
- const NO_STATE_MSG =
29
- 'No state change detected. Trigger an event to change state' ;
28
+ const NO_STATE_MSG = 'No state change detected. Trigger an event to change state' ;
30
29
// eslint-disable-next-line react/prop-types
31
30
32
31
export interface StateRouteProps {
@@ -49,7 +48,7 @@ const StateRoute = (props: StateRouteProps) => {
49
48
const { snapshot, hierarchy, snapshots, viewIndex, webMetrics } = props ;
50
49
const [ { tabs, currentTab } , dispatch ] = useStoreContext ( ) ;
51
50
const { hierarchy, sliderIndex, viewIndex } = tabs [ currentTab ] ;
52
- const isRecoil = snapshot . atomsComponents ? true : false ;
51
+ const isRecoil = ! ! snapshot . atomsComponents ;
53
52
54
53
const [ noRenderData , setNoRenderData ] = useState ( false ) ;
55
54
// component map zoom state
@@ -69,7 +68,7 @@ const StateRoute = (props: StateRouteProps) => {
69
68
</ ParentSize >
70
69
) ;
71
70
}
72
- return < div className = ' noState' > { NO_STATE_MSG } </ div > ;
71
+ return < div className = " noState" > { NO_STATE_MSG } </ div > ;
73
72
} ;
74
73
75
74
// the hierarchy gets set upon the first click on the page
@@ -88,7 +87,7 @@ const StateRoute = (props: StateRouteProps) => {
88
87
/>
89
88
) ;
90
89
}
91
- return < div className = ' noState' > { NO_STATE_MSG } </ div > ;
90
+ return < div className = " noState" > { NO_STATE_MSG } </ div > ;
92
91
} ;
93
92
94
93
const renderAtomsRelationship = ( ) => (
@@ -112,10 +111,11 @@ const StateRoute = (props: StateRouteProps) => {
112
111
if ( hierarchy ) {
113
112
return < Tree snapshot = { snapshot } /> ;
114
113
}
115
- return < div className = ' noState' > { NO_STATE_MSG } </ div > ;
114
+ return < div className = " noState" > { NO_STATE_MSG } </ div > ;
116
115
} ;
117
116
const renderWebMetrics = ( ) => {
118
- let LCPColor , FIDColor , FCPColor , TTFBColor ;
117
+ let LCPColor ; let FIDColor ; let FCPColor ; let
118
+ TTFBColor ;
119
119
120
120
if ( webMetrics . LCP <= 2000 ) LCPColor = '#0bce6b' ;
121
121
if ( webMetrics . LCP > 2000 && webMetrics . LCP < 4000 ) LCPColor = '#E56543' ;
@@ -130,44 +130,40 @@ const StateRoute = (props: StateRouteProps) => {
130
130
if ( webMetrics . TTFB > 600 ) TTFBColor = '#fc2000' ;
131
131
132
132
return (
133
- < div className = ' web-metrics-container' >
133
+ < div className = " web-metrics-container" >
134
134
< WebMetrics
135
135
color = { LCPColor }
136
136
series = { ( webMetrics . LCP / 2500 ) * 100 }
137
- formatted = { ( val ) => {
138
- return Number . isNaN ( val )
139
- ? '- ms'
140
- : ( ( val / 100 ) * 2500 ) . toFixed ( 2 ) + ' ms' ;
141
- } }
142
- label = 'LCP'
143
- name = 'Largest Contentful Paint'
144
- description = 'Measures loading performance. The benchmark is less than 2500 ms.'
137
+ formatted = { val => ( Number . isNaN ( val )
138
+ ? '- ms'
139
+ : `${ ( ( val / 100 ) * 2500 ) . toFixed ( 2 ) } ms` ) }
140
+ label = "LCP"
141
+ name = "Largest Contentful Paint"
142
+ description = "Measures loading performance. The benchmark is less than 2500 ms."
145
143
/>
146
144
< WebMetrics
147
145
color = { FIDColor }
148
146
series = { webMetrics . FID * 25 }
149
- formatted = { ( val ) => {
150
- return Number . isNaN ( val ) ? '- ms' : ( val / 25 ) . toFixed ( 2 ) + ' ms' ;
151
- } }
152
- label = 'FID'
153
- name = 'First Input Delay'
154
- description = 'Measures interactivity. The benchmark is less than 100 ms.'
147
+ formatted = { val => ( Number . isNaN ( val ) ? '- ms' : `${ ( val / 25 ) . toFixed ( 2 ) } ms` ) }
148
+ label = "FID"
149
+ name = "First Input Delay"
150
+ description = "Measures interactivity. The benchmark is less than 100 ms."
155
151
/>
156
152
< WebMetrics
157
153
color = { FCPColor }
158
154
series = { ( webMetrics . FCP / 1000 ) * 100 }
159
- formatted = { ( val ) => ( ( val / 100 ) * 1000 ) . toFixed ( 2 ) + ' ms' }
160
- label = ' FCP'
161
- name = ' First Contentful Paint'
162
- description = ' Measures the time it takes the browser to render the first piece of DOM content. No benchmark.'
155
+ formatted = { val => ` ${ ( ( val / 100 ) * 1000 ) . toFixed ( 2 ) } ms` }
156
+ label = " FCP"
157
+ name = " First Contentful Paint"
158
+ description = " Measures the time it takes the browser to render the first piece of DOM content. No benchmark."
163
159
/>
164
160
< WebMetrics
165
161
color = { TTFBColor }
166
162
series = { ( webMetrics . TTFB / 10 ) * 100 }
167
- formatted = { ( val ) => ( ( val / 100 ) * 10 ) . toFixed ( 2 ) + ' ms' }
168
- label = ' TTFB'
169
- name = ' Time to First Byte'
170
- description = ' Measures the time it takes for a browser to receive the first byte of page content. The benchmark is 600 ms.'
163
+ formatted = { val => ` ${ ( ( val / 100 ) * 10 ) . toFixed ( 2 ) } ms` }
164
+ label = " TTFB"
165
+ name = " Time to First Byte"
166
+ description = " Measures the time it takes for a browser to receive the first byte of page content. The benchmark is 600 ms."
171
167
/>
172
168
</ div >
173
169
) ;
@@ -190,61 +186,61 @@ const StateRoute = (props: StateRouteProps) => {
190
186
</ ParentSize >
191
187
) ;
192
188
}
193
- return < div className = ' noState' > { NO_STATE_MSG } </ div > ;
189
+ return < div className = " noState" > { NO_STATE_MSG } </ div > ;
194
190
} ;
195
191
196
192
return (
197
193
< Router >
198
- < div className = ' navbar' >
194
+ < div className = " navbar" >
199
195
< NavLink
200
- className = ' router-link'
201
- activeClassName = ' is-active'
196
+ className = " router-link"
197
+ activeClassName = " is-active"
202
198
exact
203
- to = '/'
199
+ to = "/"
204
200
>
205
201
Map
206
202
</ NavLink >
207
203
< NavLink
208
- className = ' router-link'
209
- activeClassName = ' is-active'
210
- to = ' /performance'
204
+ className = " router-link"
205
+ activeClassName = " is-active"
206
+ to = " /performance"
211
207
>
212
208
Performance
213
209
</ NavLink >
214
210
< NavLink
215
- className = ' router-link'
216
- activeClassName = ' is-active'
217
- to = ' /history'
211
+ className = " router-link"
212
+ activeClassName = " is-active"
213
+ to = " /history"
218
214
>
219
215
History
220
216
</ NavLink >
221
217
< NavLink
222
- className = ' router-link'
223
- activeClassName = ' is-active'
224
- to = ' /webMetrics'
218
+ className = " router-link"
219
+ activeClassName = " is-active"
220
+ to = " /webMetrics"
225
221
>
226
222
Web Metrics
227
223
</ NavLink >
228
- < NavLink className = ' router-link' activeClassName = ' is-active' to = ' /tree' >
224
+ < NavLink className = " router-link" activeClassName = " is-active" to = " /tree" >
229
225
Tree
230
226
</ NavLink >
231
227
{ isRecoil && (
232
228
< NavLink
233
- className = ' router-link'
234
- activeClassName = ' is-active'
235
- to = ' /relationship'
229
+ className = " router-link"
230
+ activeClassName = " is-active"
231
+ to = " /relationship"
236
232
>
237
233
AtomsRecoil
238
234
</ NavLink >
239
235
) }
240
236
</ div >
241
237
< Switch >
242
- < Route path = ' /performance' render = { renderPerfView } />
243
- < Route path = ' /history' render = { renderHistory } />
244
- < Route path = ' /relationship' render = { renderAtomsRelationship } />
245
- < Route path = ' /webMetrics' render = { renderWebMetrics } />
246
- < Route path = ' /tree' render = { renderTree } />
247
- < Route path = '/' render = { renderComponentMap } />
238
+ < Route path = " /performance" render = { renderPerfView } />
239
+ < Route path = " /history" render = { renderHistory } />
240
+ < Route path = " /relationship" render = { renderAtomsRelationship } />
241
+ < Route path = " /webMetrics" render = { renderWebMetrics } />
242
+ < Route path = " /tree" render = { renderTree } />
243
+ < Route path = "/" render = { renderComponentMap } />
248
244
</ Switch >
249
245
</ Router >
250
246
) ;
0 commit comments