Skip to content

Commit 701094c

Browse files
authored
chore(web-vitals): minor cleanup flyout layout (#95596)
- Removed custom stuff - Reduced vertical space **Before & After:** <img width="1491" height="958" alt="Screenshot 2025-07-15 at 12 35 25 PM" src="https://github.com/user-attachments/assets/69296be4-30f6-40e1-bb6b-ba49506443e0" />
1 parent 78220b8 commit 701094c

File tree

1 file changed

+31
-80
lines changed

1 file changed

+31
-80
lines changed
Lines changed: 31 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {useTheme} from '@emotion/react';
21
import styled from '@emotion/styled';
32

43
import ExternalLink from 'sentry/components/links/externalLink';
@@ -8,17 +7,9 @@ import {t, tct} from 'sentry/locale';
87
import {space} from 'sentry/styles/space';
98
import {WebVital} from 'sentry/utils/fields';
109
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';
1311
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';
2213
import {vitalSupportedBrowsers} from 'sentry/views/performance/vitalDetail/utils';
2314

2415
type Props = {
@@ -53,7 +44,7 @@ export const VITAL_DESCRIPTIONS: Partial<
5344
openInNewTab
5445
href="https://blog.sentry.io/how-to-make-your-web-page-faster-before-it-even-loads/"
5546
>
56-
How can I fix my FCP?
47+
How do I fix my FCP?
5748
</ExternalLink>
5849
),
5950
},
@@ -69,7 +60,7 @@ export const VITAL_DESCRIPTIONS: Partial<
6960
openInNewTab
7061
href="https://blog.sentry.io/from-lcp-to-cls-improve-your-core-web-vitals-with-image-loading-best/"
7162
>
72-
How can I fix my CLS?
63+
How do I fix my CLS score?
7364
</ExternalLink>
7465
),
7566
},
@@ -85,7 +76,7 @@ export const VITAL_DESCRIPTIONS: Partial<
8576
openInNewTab
8677
href="https://blog.sentry.io/from-lcp-to-cls-improve-your-core-web-vitals-with-image-loading-best/"
8778
>
88-
How can I fix my LCP?
79+
How do I fix my LCP score?
8980
</ExternalLink>
9081
),
9182
},
@@ -101,7 +92,7 @@ export const VITAL_DESCRIPTIONS: Partial<
10192
openInNewTab
10293
href="https://blog.sentry.io/how-i-fixed-my-brutal-ttfb/"
10394
>
104-
How can I fix my TTFB?
95+
How do I fix my TTFB score?
10596
</ExternalLink>
10697
),
10798
},
@@ -114,34 +105,23 @@ export const VITAL_DESCRIPTIONS: Partial<
114105
),
115106
link: (
116107
<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?
118109
</ExternalLink>
119110
),
120111
},
121112
};
122113

123114
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)]!;
127115
const status = score === undefined ? undefined : scoreToStatus(score);
128116

129117
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>
145125
);
146126
}
147127

@@ -154,17 +134,10 @@ export function WebVitalDescription({score, value, webVital}: Props) {
154134
<WebVitalDetailHeader score={score} value={value} webVital={webVital} />
155135
<DescriptionWrapper>
156136
{longDescription}
157-
{link}
137+
{tct(` [webVital] is available for the following browsers:`, {
138+
webVital: webVital.toUpperCase(),
139+
})}
158140
</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>
168141
<SupportedBrowsers>
169142
{Object.values(Browser).map(browser => (
170143
<BrowserItem key={browser}>
@@ -179,14 +152,19 @@ export function WebVitalDescription({score, value, webVital}: Props) {
179152
</BrowserItem>
180153
))}
181154
</SupportedBrowsers>
155+
<ReferenceLink>{link}</ReferenceLink>
182156
</div>
183157
);
184158
}
185159

186160
const SupportedBrowsers = styled('div')`
187161
display: inline-flex;
188162
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)};
190168
`;
191169

192170
const BrowserItem = styled('div')`
@@ -195,52 +173,25 @@ const BrowserItem = styled('div')`
195173
gap: ${space(1)};
196174
`;
197175

198-
const Header = styled('span')`
199-
display: flex;
200-
justify-content: space-between;
201-
margin-bottom: ${space(3)};
202-
`;
203-
204176
const DescriptionWrapper = styled('div')`
205177
display: flex;
206178
flex-direction: column;
207-
margin-bottom: ${space(2)};
179+
margin-bottom: ${space(1)};
208180
`;
209181

210182
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;
215184
`;
216185

217-
const WebVitalName = styled('h4')`
218-
margin-bottom: ${space(1)};
219-
max-width: 400px;
186+
const WebVitalName = styled('h6')`
187+
margin-bottom: 0;
220188
${p => p.theme.overflowEllipsis}
221189
`;
222190

223-
const ScoreBadge = styled('div')<{status: PerformanceScore}>`
191+
const WebVitalScore = styled('div')`
224192
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;
244194
font-weight: ${p => p.theme.fontWeight.bold};
245-
font-size: ${p => p.theme.fontSize.lg};
195+
margin-bottom: ${space(1)};
196+
gap: ${space(1)};
246197
`;

0 commit comments

Comments
 (0)