Skip to content

Commit

Permalink
Logged-in Performance Profiler: Fix UI issues with status badges and …
Browse files Browse the repository at this point in the history
…performance score ring (#94880)

* Fixed status badge positioning and alignment.

* Fix text color in performance score ring.

Also update the code to pull color variables from the color-studio package to make future maintenance easier.

* Fix sizing of text in performance score ring.

* Increase the size of the performance score ring when the tab is selected on mobile.
  • Loading branch information
matt-west authored Sep 25, 2024
1 parent 1d8d7e8 commit 259e53d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ export const CircularPerformanceScore = ( {
numberOfSteps={ steps }
showProgressText={ false }
/>
<div className="circular-performance-score">{ score }</div>
<div
className={ `circular-performance-score ${
size > 48 && 'circular-performance-score--large'
} ` }
>
{ score }
</div>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
@import "@automattic/color-studio/dist/color-variables";
@import "@automattic/components/src/styles/typography";

.circular-performance-bar {
position: relative;
display: inline-block;
color: $studio-black;

&.good {
color: #00ba37;
.circular__progress-bar .circular__progress-bar-fill-circle {
stroke: #00ba37;
stroke: $studio-green-30;
}
}

&.needs-improvement {
color: #d67709;
.circular__progress-bar .circular__progress-bar-fill-circle {
stroke: #d67709;
stroke: $studio-orange-40;
}
}

&.poor {
color: #d63638;
.circular__progress-bar .circular__progress-bar-fill-circle {
stroke: #d63638;
stroke: $studio-red-50;
}
}
}
Expand All @@ -34,5 +33,9 @@
font-family: $font-sf-pro-display;
font-size: $font-size-header-small;
font-weight: 400;

&--large {
font-size: 1.75rem;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ type HeaderProps = {
displayName: string;
metricKey: Metrics;
metricValue: number;
isActive?: boolean;
};

const CardHeader = ( props: HeaderProps ) => {
const { displayName, metricKey, metricValue } = props;
const { displayName, metricKey, metricValue, isActive } = props;
const status = mapThresholdsToStatus( metricKey, metricValue );
const isPerformanceScoreSelected = metricKey === 'overall';

Expand All @@ -35,7 +36,7 @@ const CardHeader = ( props: HeaderProps ) => {

{ isPerformanceScoreSelected ? (
<div className="metric-tab-bar-v2__tab-metric" style={ { marginTop: '6px' } }>
<CircularPerformanceScore score={ metricValue } size={ 48 } />
<CircularPerformanceScore score={ metricValue } size={ isActive ? 72 : 48 } />
</div>
) : (
<span
Expand Down Expand Up @@ -91,6 +92,7 @@ export const CoreWebVitalsAccordionV2 = ( props: Props ) => {
displayName={ displayName }
metricKey={ key as Metrics }
metricValue={ props[ key as Metrics ] }
isActive={ key === activeTab }
/>
}
hideSummary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const CoreWebVitalsDetailsV2: React.FC< CoreWebVitalsDetailsProps > = ( {
marginTop: '16px',
} }
>
<CircularPerformanceScore score={ value } size={ 76 } />
<CircularPerformanceScore score={ value } size={ 72 } />
</div>
) : (
displayValue( activeTab as Metrics, value )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ $blueberry-color: #3858e9;
display: flex;
gap: 24px;

@media (max-width: $break-mobile) {
@media (max-width: $break-large) {
flex-direction: column;
gap: 0;
}
Expand Down
12 changes: 4 additions & 8 deletions client/performance-profiler/components/status-section/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
color: #000;
display: flex;
flex-direction: column;
align-items: center;
align-items: flex-end;
gap: 12px;


.status-badge {
display: flex;
padding: 2px 10px;
Expand All @@ -19,11 +18,6 @@
border-radius: 4px;
font-weight: 500;
flex-shrink: 0;
width: 100%;

@media (max-width: $break-mobile) {
width: unset;
}

&.poor {
background: var(--studio-red-5);
Expand All @@ -47,8 +41,10 @@
}
}

@media (max-width: $break-mobile) {
@media (max-width: $break-large) {
flex-direction: row;
width: 100%;
align-items: center;
margin-bottom: 24px;
}
}

0 comments on commit 259e53d

Please sign in to comment.