Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* Metrics card component - displays a single metric value.
*/
interface MetricsCardProps {
title: string;
value: number;
unit?: string;
decimals?: number;
compact?: boolean;
}
export default function MetricsCard({
title,
value,
unit,
decimals = 0,
compact = false,
}: MetricsCardProps) {
const formattedValue = value.toFixed(decimals);
if (compact) {
return (
<div className="bg-gray-50 border border-gray-200 rounded-md p-2">
<div className="text-xs text-gray-600 mb-1">{title}</div>
<div className="text-sm font-mono font-semibold text-gray-900">
{formattedValue}
{unit && <span className="text-xs text-gray-500 ml-1">{unit}</span>}
</div>
</div>
);
}
return (
<div className="bg-white border border-gray-200 rounded-lg p-4 shadow-sm">
<div className="text-sm text-gray-600 mb-2">{title}</div>
<div className="text-2xl font-mono font-bold text-gray-900">
{formattedValue}
{unit && <span className="text-sm text-gray-500 ml-2">{unit}</span>}
</div>
</div>
);
}