| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 'use client';
- import { ArrowUp, ArrowDown, LucideIcon } from 'lucide-react';
- interface StatCardProps {
- title: string;
- value: string | number;
- icon: LucideIcon;
- trend?: string;
- trendUp?: boolean;
- color?: string;
- }
- export default function DataStats({ title, value, icon: Icon, trend, trendUp, color = "blue" }: StatCardProps) {
-
- const colorStyles: Record<string, string> = {
- blue: "bg-blue-50 text-blue-600",
- green: "bg-green-50 text-green-600",
- yellow: "bg-yellow-50 text-yellow-600",
- red: "bg-red-50 text-red-600",
- purple: "bg-purple-50 text-purple-600",
- };
- return (
- <div className="bg-white rounded-xl p-6 shadow-sm border border-slate-100">
- <div className="flex justify-between items-start">
- <div>
- <p className="text-sm font-medium text-slate-500 mb-1">{title}</p>
- <h3 className="text-2xl font-bold text-slate-900">{value}</h3>
- </div>
- <div className={`p-3 rounded-lg ${colorStyles[color] || colorStyles.blue}`}>
- <Icon size={24} />
- </div>
- </div>
-
- {trend && (
- <div className="mt-4 flex items-center text-sm">
- <span className={`flex items-center font-medium ${trendUp ? 'text-green-600' : 'text-red-600'}`}>
- {trendUp ? <ArrowUp size={16} className="mr-1" /> : <ArrowDown size={16} className="mr-1" />}
- {trend}
- </span>
- <span className="text-slate-400 ml-2">较上月</span>
- </div>
- )}
- </div>
- );
- }
|