performance page polish

This commit is contained in:
Francis Cao committed 2026-03-05 12:21:34 -08:00
1 parent 31caa0d62e
commit 383922ab17
9 files changed
+113 -54

No files matched your search

+7 -1
View File
@@ -27,6 +27,7 @@ export interface ListTableProps {
showPercentage?: boolean;
itemCount?: number;
currency?: string;
formatCount?: (n: number) => string;
}
export function ListTable({
@@ -40,6 +41,7 @@ export function ListTable({
showPercentage = true,
itemCount = 10,
currency,
formatCount,
}: ListTableProps) {
const { t, labels } = useMessages();
const { isPhone } = useMobile();
@@ -57,6 +59,7 @@ export function ListTable({
showPercentage={showPercentage}
change={renderChange ? renderChange(row, index) : null}
currency={currency}
formatCount={formatCount}
isPhone={isPhone}
/>
);
@@ -106,6 +109,7 @@ const AnimatedRow = ({
animate,
showPercentage = true,
currency,
formatCount,
isPhone,
}) => {
const props = useSpring({
@@ -135,7 +139,9 @@ const AnimatedRow = ({
<AnimatedDiv title={props?.y as any}>
{currency
? props.y?.to(n => formatLongCurrency(n, currency))
: props.y?.to(formatLongNumber)}
: formatCount
? props.y?.to(formatCount)
: props.y?.to(formatLongNumber)}
</AnimatedDiv>
</Text>
</Row>
@@ -3,7 +3,9 @@
}
.card:hover {
box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 15%, transparent);
box-shadow:
0 0 0 1px color-mix(in srgb, var(--primary) 40%, transparent),
0 0 6px color-mix(in srgb, var(--primary) 15%, transparent);
}
.card.selected {
+12 -1
View File
@@ -1,4 +1,7 @@
import { config, useSpring } from '@react-spring/web';
import { Column, Text } from '@umami/react-zen';
import { useRef } from 'react';
import { AnimatedDiv } from '@/components/common/AnimatedDiv';
import { useMessages } from '@/components/hooks';
import { WEB_VITALS_THRESHOLDS } from '@/lib/constants';
import { formatNumber } from '@/lib/format';
@@ -31,6 +34,14 @@ export const PerformanceCard = ({
}: PerformanceCardProps) => {
const { t, labels } = useMessages();
const rating = getRating(metric, value);
const prevMetricRef = useRef(metric);
const metricChanged = prevMetricRef.current !== metric;
if (metricChanged) prevMetricRef.current = metric;
const spring = useSpring({
value: !Number.isNaN(value) ? value : 0,
config: metricChanged ? { duration: 0 } : config.default,
});
return (
<Column
@@ -49,7 +60,7 @@ export const PerformanceCard = ({
{label}
</Text>
<Text size="4xl" weight="bold" wrap="nowrap">
{formatValue(value)}
<AnimatedDiv>{spring.value.to(n => formatValue(n))}</AnimatedDiv>
</Text>
<Text size="sm" className={styles.rating}>
{t(labels[rating === 'needs-improvement' ? 'needsImprovement' : rating])}