File size: 1,507 Bytes
5f7dc7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
interface StatCardProps {
  label: string;
  value: string | number;
  icon?: React.ReactNode;
  accent?: "primary" | "success" | "warning" | "info";
  subtitle?: string;
}

const accentMap = {
  primary: { bg: "var(--primary-ghost)", color: "var(--primary)" },
  success: { bg: "var(--success-bg)", color: "var(--success)" },
  warning: { bg: "var(--warning-bg)", color: "var(--warning)" },
  info: { bg: "var(--info-bg)", color: "var(--info)" },
};

export default function StatCard({
  label,
  value,
  icon,
  accent = "primary",
  subtitle,
}: StatCardProps) {
  const colors = accentMap[accent];

  return (
    <div className="glass-card p-5 animate-fade-in">
      <div className="flex items-start justify-between mb-3">
        <span
          className="text-[10px] font-semibold uppercase tracking-[0.08em] font-mono"
          style={{ color: "var(--text-muted)" }}
        >
          {label}
        </span>
        {icon && (
          <span
            className="w-8 h-8 rounded-lg flex items-center justify-center text-sm"
            style={{ background: colors.bg, color: colors.color }}
          >
            {icon}
          </span>
        )}
      </div>
      <p
        className="text-2xl font-bold tracking-tight"
        style={{ color: colors.color }}
      >
        {value}
      </p>
      {subtitle && (
        <p
          className="text-xs mt-1"
          style={{ color: "var(--text-muted)" }}
        >
          {subtitle}
        </p>
      )}
    </div>
  );
}