1
- import { useTheme } from '@emotion/react' ;
2
1
import styled from '@emotion/styled' ;
3
2
4
3
import ExternalLink from 'sentry/components/links/externalLink' ;
@@ -8,17 +7,9 @@ import {t, tct} from 'sentry/locale';
8
7
import { space } from 'sentry/styles/space' ;
9
8
import { WebVital } from 'sentry/utils/fields' ;
10
9
import { Browser } from 'sentry/utils/performance/vitals/constants' ;
11
- import { ORDER } from 'sentry/views/insights/browser/webVitals/components/charts/performanceScoreChart' ;
12
- import { Dot } from 'sentry/views/insights/browser/webVitals/components/webVitalMeters' ;
10
+ import { PerformanceBadge } from 'sentry/views/insights/browser/webVitals/components/performanceBadge' ;
13
11
import type { WebVitals } from 'sentry/views/insights/browser/webVitals/types' ;
14
- import {
15
- makePerformanceScoreColors ,
16
- type PerformanceScore ,
17
- } from 'sentry/views/insights/browser/webVitals/utils/performanceScoreColors' ;
18
- import {
19
- scoreToStatus ,
20
- STATUS_TEXT ,
21
- } from 'sentry/views/insights/browser/webVitals/utils/scoreToStatus' ;
12
+ import { scoreToStatus } from 'sentry/views/insights/browser/webVitals/utils/scoreToStatus' ;
22
13
import { vitalSupportedBrowsers } from 'sentry/views/performance/vitalDetail/utils' ;
23
14
24
15
type Props = {
@@ -53,7 +44,7 @@ export const VITAL_DESCRIPTIONS: Partial<
53
44
openInNewTab
54
45
href = "https://blog.sentry.io/how-to-make-your-web-page-faster-before-it-even-loads/"
55
46
>
56
- How can I fix my FCP?
47
+ How do I fix my FCP?
57
48
</ ExternalLink >
58
49
) ,
59
50
} ,
@@ -69,7 +60,7 @@ export const VITAL_DESCRIPTIONS: Partial<
69
60
openInNewTab
70
61
href = "https://blog.sentry.io/from-lcp-to-cls-improve-your-core-web-vitals-with-image-loading-best/"
71
62
>
72
- How can I fix my CLS?
63
+ How do I fix my CLS score ?
73
64
</ ExternalLink >
74
65
) ,
75
66
} ,
@@ -85,7 +76,7 @@ export const VITAL_DESCRIPTIONS: Partial<
85
76
openInNewTab
86
77
href = "https://blog.sentry.io/from-lcp-to-cls-improve-your-core-web-vitals-with-image-loading-best/"
87
78
>
88
- How can I fix my LCP?
79
+ How do I fix my LCP score ?
89
80
</ ExternalLink >
90
81
) ,
91
82
} ,
@@ -101,7 +92,7 @@ export const VITAL_DESCRIPTIONS: Partial<
101
92
openInNewTab
102
93
href = "https://blog.sentry.io/how-i-fixed-my-brutal-ttfb/"
103
94
>
104
- How can I fix my TTFB?
95
+ How do I fix my TTFB score ?
105
96
</ ExternalLink >
106
97
) ,
107
98
} ,
@@ -114,34 +105,23 @@ export const VITAL_DESCRIPTIONS: Partial<
114
105
) ,
115
106
link : (
116
107
< ExternalLink openInNewTab href = "https://blog.sentry.io/what-is-inp/" >
117
- How can I fix my INP?
108
+ How do I fix my INP score ?
118
109
</ ExternalLink >
119
110
) ,
120
111
} ,
121
112
} ;
122
113
123
114
export function WebVitalDetailHeader ( { score, value, webVital} : Props ) {
124
- const theme = useTheme ( ) ;
125
- const colors = theme . chart . getColorPalette ( 4 ) ;
126
- const dotColor = colors [ ORDER . indexOf ( webVital ) ] ! ;
127
115
const status = score === undefined ? undefined : scoreToStatus ( score ) ;
128
116
129
117
return (
130
- < Header >
131
- < span >
132
- < WebVitalName > { `${ WEB_VITAL_FULL_NAME_MAP [ webVital ] } (P75)` } </ WebVitalName >
133
- < Value >
134
- < Dot color = { dotColor } />
135
- { value ?? ' \u2014 ' }
136
- </ Value >
137
- </ span >
138
- { status && score && (
139
- < ScoreBadge status = { status } >
140
- < StatusText > { STATUS_TEXT [ status ] } </ StatusText >
141
- < StatusScore > { score } </ StatusScore >
142
- </ ScoreBadge >
143
- ) }
144
- </ Header >
118
+ < div >
119
+ < WebVitalName > { `${ WEB_VITAL_FULL_NAME_MAP [ webVital ] } (P75)` } </ WebVitalName >
120
+ < WebVitalScore >
121
+ < Value > { value ?? ' \u2014 ' } </ Value >
122
+ { status && score && < PerformanceBadge score = { score } /> }
123
+ </ WebVitalScore >
124
+ </ div >
145
125
) ;
146
126
}
147
127
@@ -154,17 +134,10 @@ export function WebVitalDescription({score, value, webVital}: Props) {
154
134
< WebVitalDetailHeader score = { score } value = { value } webVital = { webVital } />
155
135
< DescriptionWrapper >
156
136
{ longDescription }
157
- { link }
137
+ { tct ( ` [webVital] is available for the following browsers:` , {
138
+ webVital : webVital . toUpperCase ( ) ,
139
+ } ) }
158
140
</ DescriptionWrapper >
159
-
160
- < p >
161
- < b >
162
- { tct (
163
- `At the moment, there is support for [webVital] in the following browsers:` ,
164
- { webVital : webVital . toUpperCase ( ) }
165
- ) }
166
- </ b >
167
- </ p >
168
141
< SupportedBrowsers >
169
142
{ Object . values ( Browser ) . map ( browser => (
170
143
< BrowserItem key = { browser } >
@@ -179,14 +152,19 @@ export function WebVitalDescription({score, value, webVital}: Props) {
179
152
</ BrowserItem >
180
153
) ) }
181
154
</ SupportedBrowsers >
155
+ < ReferenceLink > { link } </ ReferenceLink >
182
156
</ div >
183
157
) ;
184
158
}
185
159
186
160
const SupportedBrowsers = styled ( 'div' ) `
187
161
display: inline-flex;
188
162
gap: ${ space ( 2 ) } ;
189
- margin-bottom: ${ space ( 3 ) } ;
163
+ margin-bottom: ${ space ( 2 ) } ;
164
+ ` ;
165
+
166
+ const ReferenceLink = styled ( 'div' ) `
167
+ margin-bottom: ${ space ( 2 ) } ;
190
168
` ;
191
169
192
170
const BrowserItem = styled ( 'div' ) `
@@ -195,52 +173,25 @@ const BrowserItem = styled('div')`
195
173
gap: ${ space ( 1 ) } ;
196
174
` ;
197
175
198
- const Header = styled ( 'span' ) `
199
- display: flex;
200
- justify-content: space-between;
201
- margin-bottom: ${ space ( 3 ) } ;
202
- ` ;
203
-
204
176
const DescriptionWrapper = styled ( 'div' ) `
205
177
display: flex;
206
178
flex-direction: column;
207
- margin-bottom: ${ space ( 2 ) } ;
179
+ margin-bottom: ${ space ( 1 ) } ;
208
180
` ;
209
181
210
182
const Value = styled ( 'h2' ) `
211
- display: flex;
212
- align-items: center;
213
- font-weight: ${ p => p . theme . fontWeight . normal } ;
214
- margin-bottom: ${ space ( 1 ) } ;
183
+ margin-bottom: 0;
215
184
` ;
216
185
217
- const WebVitalName = styled ( 'h4' ) `
218
- margin-bottom: ${ space ( 1 ) } ;
219
- max-width: 400px;
186
+ const WebVitalName = styled ( 'h6' ) `
187
+ margin-bottom: 0;
220
188
${ p => p . theme . overflowEllipsis }
221
189
` ;
222
190
223
- const ScoreBadge = styled ( 'div' ) < { status : PerformanceScore } > `
191
+ const WebVitalScore = styled ( 'div' ) `
224
192
display: flex;
225
- justify-content: center;
226
- align-items: center;
227
- flex-direction: column;
228
- color: ${ p => makePerformanceScoreColors ( p . theme ) [ p . status ] . normal } ;
229
- background-color: ${ p => makePerformanceScoreColors ( p . theme ) [ p . status ] . light } ;
230
- border: solid 1px ${ p => makePerformanceScoreColors ( p . theme ) [ p . status ] . light } ;
231
- padding: ${ space ( 0.5 ) } ;
232
- text-align: center;
233
- height: 60px;
234
- width: 60px;
235
- border-radius: 60px;
236
- ` ;
237
-
238
- const StatusText = styled ( 'span' ) `
239
- padding-top: ${ space ( 0.5 ) } ;
240
- font-size: ${ p => p . theme . fontSize . sm } ;
241
- ` ;
242
-
243
- const StatusScore = styled ( 'span' ) `
193
+ align-items: anchor-center;
244
194
font-weight: ${ p => p . theme . fontWeight . bold } ;
245
- font-size: ${ p => p . theme . fontSize . lg } ;
195
+ margin-bottom: ${ space ( 1 ) } ;
196
+ gap: ${ space ( 1 ) } ;
246
197
` ;
0 commit comments