| 1 |
/** |
| 2 |
* Stat Card Component |
| 3 |
* Ultra-minimal SaaS-style stat card |
| 4 |
*/ |
| 5 |
|
| 6 |
import React from "react"; |
| 7 |
import { LucideIcon } from "lucide-react"; |
| 8 |
|
| 9 |
interface StatCardProps { |
| 10 |
title: string; |
| 11 |
value: string | number; |
| 12 |
icon: LucideIcon; |
| 13 |
trend?: { |
| 14 |
value: number; |
| 15 |
isPositive: boolean; |
| 16 |
}; |
| 17 |
color?: "blue" | "green" | "purple" | "orange"; |
| 18 |
loading?: boolean; |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Stat Card Component - Ultra minimal design |
| 23 |
*/ |
| 24 |
export const StatCard: React.FC<StatCardProps> = ({ |
| 25 |
title, |
| 26 |
value, |
| 27 |
icon: Icon, |
| 28 |
trend, |
| 29 |
color = "blue", |
| 30 |
loading = false, |
| 31 |
}) => { |
| 32 |
return ( |
| 33 |
<div className="bg-white dark:bg-gray-800 rounded-lg border border-gray-100 dark:border-gray-700/50 p-3 hover:border-gray-200 dark:hover:border-gray-600 transition-colors"> |
| 34 |
<div className="flex items-start justify-between"> |
| 35 |
<div className="flex-1"> |
| 36 |
<p className="text-xs text-gray-500 dark:text-gray-400 mb-1"> |
| 37 |
{title} |
| 38 |
</p> |
| 39 |
{loading ? ( |
| 40 |
<div className="h-6 w-20 bg-gray-100 dark:bg-gray-700 rounded animate-pulse" /> |
| 41 |
) : ( |
| 42 |
<p className="text-xl font-semibold text-gray-900 dark:text-white"> |
| 43 |
{value} |
| 44 |
</p> |
| 45 |
)} |
| 46 |
{trend && !loading && ( |
| 47 |
<div className="flex items-center gap-1 mt-2"> |
| 48 |
<span |
| 49 |
className={`text-xs font-medium ${trend.isPositive ? "text-green-600 dark:text-green-400" : "text-red-600 dark:text-red-400"}`} |
| 50 |
> |
| 51 |
{trend.isPositive ? "↑" : "↓"} {Math.abs(trend.value)}% |
| 52 |
</span> |
| 53 |
<span className="text-xs text-gray-400 dark:text-gray-500"> |
| 54 |
vs last month |
| 55 |
</span> |
| 56 |
</div> |
| 57 |
)} |
| 58 |
</div> |
| 59 |
<div className={`p-2.5 rounded-lg bg-gray-50 dark:bg-gray-700/50`}> |
| 60 |
<Icon |
| 61 |
className={`w-4 h-4 ${ |
| 62 |
color === "blue" |
| 63 |
? "text-blue-600 dark:text-blue-400" |
| 64 |
: color === "green" |
| 65 |
? "text-green-600 dark:text-green-400" |
| 66 |
: color === "purple" |
| 67 |
? "text-purple-600 dark:text-purple-400" |
| 68 |
: "text-orange-600 dark:text-orange-400" |
| 69 |
}`} |
| 70 |
/> |
| 71 |
</div> |
| 72 |
</div> |
| 73 |
</div> |
| 74 |
); |
| 75 |
}; |
| 76 |
|
| 77 |
export default StatCard; |
| 78 |
|