Skip to content

Commit 4390e44

Browse files
Christopher StamperChristopher Stamper
authored andcommitted
Added metric ranges to popup for web metrics
1 parent cbdc296 commit 4390e44

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

src/app/components/StateRoute/StateRoute.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ const StateRoute = (props: StateRouteProps) => {
127127
formatted={(_) =>
128128
typeof webMetrics.LCP !== 'number' ? '- ms' : `${webMetrics.LCP.toFixed(2)} ms`
129129
}
130+
score={['2500 ms', '4000 ms']}
130131
label='Largest Contentful Paint'
131132
name='Largest Contentful Paint'
132133
description='Measures loading performance. The benchmark is less than 2500 ms.'
@@ -137,6 +138,7 @@ const StateRoute = (props: StateRouteProps) => {
137138
formatted={(_) =>
138139
typeof webMetrics.FID !== 'number' ? '- ms' : `${webMetrics.FID.toFixed(2)} ms`
139140
}
141+
score={['100 ms', '300 ms']}
140142
label='First Input Delay'
141143
name='First Input Delay'
142144
description='Measures interactivity. The benchmark is less than 100 ms.'
@@ -147,6 +149,7 @@ const StateRoute = (props: StateRouteProps) => {
147149
formatted={(_) =>
148150
typeof webMetrics.FCP !== 'number' ? '- ms' : `${webMetrics.FCP.toFixed(2)} ms`
149151
}
152+
score={['1800 ms', '3000 ms']}
150153
label='First Contentful Paint'
151154
name='First Contentful Paint'
152155
description='Measures the time it takes the browser to render the first piece of DOM content. No benchmark.'
@@ -157,6 +160,7 @@ const StateRoute = (props: StateRouteProps) => {
157160
formatted={(_) =>
158161
typeof webMetrics.TTFB !== 'number' ? '- ms' : `${webMetrics.TTFB.toFixed(2)} ms`
159162
}
163+
score={['800 ms', '1800 ms']}
160164
label='Time To First Byte'
161165
name='Time to First Byte'
162166
description='Measures the time it takes for a browser to receive the first byte of page content. The benchmark is 600 ms.'
@@ -171,6 +175,7 @@ const StateRoute = (props: StateRouteProps) => {
171175
: `${webMetrics.CLS < 0.01 ? '~0' : webMetrics.CLS.toFixed(2)}`
172176
}`
173177
}
178+
score={['0.1', '0.25']}
174179
label='Cumulative Layout Shift'
175180
name='Cumulative Layout Shift'
176181
description={`Quantifies the visual stability of a web page by measuring layout shifts during the application's loading and interaction.`}
@@ -181,6 +186,7 @@ const StateRoute = (props: StateRouteProps) => {
181186
formatted={(_) =>
182187
typeof webMetrics.INP !== 'number' ? '- ms' : `${webMetrics.INP.toFixed(2)} ms`
183188
}
189+
score={['200 ms', '500 ms']}
184190
label='Interaction to Next Paint'
185191
name='Interaction to Next Paint'
186192
description={`Assesses a page's overall responsiveness to user interactions by observing the latency of all click, tap, and keyboard interactions that occur throughout the lifespan of a user's visit to a page`}

src/app/components/WebMetrics.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ const radialGraph = (props) => {
121121
<strong>{props.name}</strong>
122122
</p>
123123
<p>{props.description}</p>
124+
<p>
125+
<span style={{ color: '#0bce6b' }}>Good: </span>
126+
{`< ${props.score[0]}`}
127+
</p>
128+
<p>
129+
<span style={{ color: '#fc5a03' }}>Needs Improvement: </span>
130+
{`< ${props.score[1]}`}
131+
</p>
132+
<p>
133+
<span style={{ color: '#fc2000' }}>Poor: </span>
134+
{`> ${props.score[1]}`}
135+
</p>
124136
</div>
125137
</Hover>
126138
</ReactHover>

src/app/styles/layout/_stateContainer.scss

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
margin: 6px;
4040
}
4141

42-
.state-container .componentMapContainer{
42+
.state-container .componentMapContainer {
4343
height: 95% !important;
4444
}
4545

@@ -206,7 +206,7 @@
206206
}
207207

208208
#hover-box {
209-
max-width: 150px;
209+
max-width: 230px;
210210
background-color: #51565e;
211211
border-radius: 5px;
212212
color: white;
@@ -218,17 +218,17 @@
218218

219219
// tool tip styles
220220

221-
.visx-tooltip{
221+
.visx-tooltip {
222222
overflow-y: auto;
223223
overflow-wrap: break-word;
224-
pointer-events:all !important;
224+
pointer-events: all !important;
225225
}
226226

227227
.tooltipKey {
228228
margin-bottom: -1px;
229229
}
230230

231-
.historyToolTip{
231+
.historyToolTip {
232232
z-index: 2;
233233
}
234234

@@ -253,14 +253,13 @@
253253
padding: 0px;
254254
overflow-y: auto;
255255
max-height: 30vh;
256-
scrollbar-color:#919499 #51565e;
256+
scrollbar-color: #919499 #51565e;
257257
}
258258

259259
.tooltipData-JSONTree::-webkit-scrollbar-thumb {
260-
background:#919499;
261-
260+
background: #919499;
262261
}
263262

264-
.tooltipData-JSONTree::-webkit-scrollbar-track{
265-
background:#51565e;
263+
.tooltipData-JSONTree::-webkit-scrollbar-track {
264+
background: #51565e;
266265
}

0 commit comments

Comments
 (0)