sitcod3 commited on
Commit
4ac095b
·
verified ·
1 Parent(s): 2ca7476

Upload src/components/StatCard.tsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. src/components/StatCard.tsx +149 -0
src/components/StatCard.tsx ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { LucideIcon, TrendingUp, TrendingDown, Minus } from "lucide-react";
2
+ import { cn } from "../utils/cn";
3
+
4
+ interface StatCardProps {
5
+ title: string;
6
+ value: string | number;
7
+ icon: LucideIcon;
8
+ iconColor?: "indigo" | "emerald" | "amber" | "rose" | "teal" | "blue" | "purple";
9
+ change?: {
10
+ value: string;
11
+ isPositive?: boolean | null;
12
+ period?: string;
13
+ };
14
+ subtitle?: string;
15
+ progress?: number; // 0 to 100
16
+ className?: string;
17
+ }
18
+
19
+ const colorMap = {
20
+ indigo: {
21
+ bg: "bg-indigo-500/10",
22
+ border: "border-indigo-500/20",
23
+ text: "text-indigo-400",
24
+ glow: "group-hover:border-indigo-500/40",
25
+ },
26
+ emerald: {
27
+ bg: "bg-emerald-500/10",
28
+ border: "border-emerald-500/20",
29
+ text: "text-emerald-400",
30
+ glow: "group-hover:border-emerald-500/40",
31
+ },
32
+ amber: {
33
+ bg: "bg-amber-500/10",
34
+ border: "border-amber-500/20",
35
+ text: "text-amber-400",
36
+ glow: "group-hover:border-amber-500/40",
37
+ },
38
+ rose: {
39
+ bg: "bg-rose-500/10",
40
+ border: "border-rose-500/20",
41
+ text: "text-rose-400",
42
+ glow: "group-hover:border-rose-500/40",
43
+ },
44
+ teal: {
45
+ bg: "bg-teal-500/10",
46
+ border: "border-teal-500/20",
47
+ text: "text-teal-400",
48
+ glow: "group-hover:border-teal-500/40",
49
+ },
50
+ blue: {
51
+ bg: "bg-blue-500/10",
52
+ border: "border-blue-500/20",
53
+ text: "text-blue-400",
54
+ glow: "group-hover:border-blue-500/40",
55
+ },
56
+ purple: {
57
+ bg: "bg-purple-500/10",
58
+ border: "border-purple-500/20",
59
+ text: "text-purple-400",
60
+ glow: "group-hover:border-purple-500/40",
61
+ },
62
+ };
63
+
64
+ export default function StatCard({
65
+ title,
66
+ value,
67
+ icon: Icon,
68
+ iconColor = "indigo",
69
+ change,
70
+ subtitle,
71
+ progress,
72
+ className,
73
+ }: StatCardProps) {
74
+ const c = colorMap[iconColor];
75
+
76
+ return (
77
+ <div
78
+ className={cn(
79
+ "group relative bg-white/5 hover:bg-white/10 backdrop-blur-md border border-white/10 rounded-xl p-5 transition-all duration-300 shadow-[0_8px_32px_-8px_rgba(6,10,12,0.65)] overflow-hidden",
80
+ className
81
+ )}
82
+ >
83
+ <div className="absolute inset-0 bg-gradient-to-br from-white/[0.03] to-transparent pointer-events-none" />
84
+ <div className="relative z-10 flex justify-between items-start">
85
+ <div>
86
+ <p className="text-xs font-semibold uppercase tracking-wider text-zinc-400 font-sans">
87
+ {title}
88
+ </p>
89
+ <h3 className="text-2xl font-bold text-zinc-100 mt-2 tracking-tight font-mono">
90
+ {value}
91
+ </h3>
92
+ {subtitle && (
93
+ <p className="text-xs text-zinc-500 mt-1 font-sans">{subtitle}</p>
94
+ )}
95
+ </div>
96
+ <div
97
+ className={cn(
98
+ "p-2.5 rounded-xl border transition-transform duration-300 group-hover:scale-110 shadow-[inset_0_1px_1px_rgba(246,248,242,0.1)]",
99
+ c.bg,
100
+ c.border
101
+ )}
102
+ >
103
+ <Icon className={cn("w-5 h-5 drop-shadow-[0_0_8px_currentColor]", c.text)} />
104
+ </div>
105
+ </div>
106
+
107
+ {progress !== undefined && (
108
+ <div className="relative z-10 mt-4 space-y-1.5">
109
+ <div className="flex justify-between text-[11px] text-zinc-400 font-sans font-medium">
110
+ <span>Capacity</span>
111
+ <span className="font-mono">{Math.round(progress)}%</span>
112
+ </div>
113
+ <div className="w-full h-1.5 bg-black/50 border border-white/5 rounded-full overflow-hidden">
114
+ <div
115
+ className={cn("h-full rounded-full transition-all duration-500", c.text.replace("text-", "bg-"))}
116
+ style={{ width: `${Math.min(100, Math.max(0, progress))}%`, boxShadow: '0 0 10px currentColor' }}
117
+ />
118
+ </div>
119
+ </div>
120
+ )}
121
+
122
+ {change && (
123
+ <div className="relative z-10 mt-3.5 flex items-center text-xs font-medium font-sans">
124
+ {change.isPositive === true && (
125
+ <span className="flex items-center text-emerald-400 mr-1.5">
126
+ <TrendingUp className="w-3.5 h-3.5 mr-0.5" />
127
+ <span className="font-mono">{change.value}</span>
128
+ </span>
129
+ )}
130
+ {change.isPositive === false && (
131
+ <span className="flex items-center text-rose-400 mr-1.5">
132
+ <TrendingDown className="w-3.5 h-3.5 mr-0.5" />
133
+ <span className="font-mono">{change.value}</span>
134
+ </span>
135
+ )}
136
+ {change.isPositive === null && (
137
+ <span className="flex items-center text-zinc-400 mr-1.5">
138
+ <Minus className="w-3.5 h-3.5 mr-0.5" />
139
+ <span className="font-mono">{change.value}</span>
140
+ </span>
141
+ )}
142
+ <span className="text-zinc-500 font-normal">
143
+ {change.period || "vs last month"}
144
+ </span>
145
+ </div>
146
+ )}
147
+ </div>
148
+ );
149
+ }