From 64878ac8cf770b7b1e494bf6dd30a92e8c06478e Mon Sep 17 00:00:00 2001 From: 15945162479 <15945162479@qq.com> Date: Sat, 13 Dec 2025 14:46:18 +0800 Subject: [PATCH] Add File --- src/family/components/MetricCard.tsx | 69 ++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/family/components/MetricCard.tsx diff --git a/src/family/components/MetricCard.tsx b/src/family/components/MetricCard.tsx new file mode 100644 index 0000000..fd15368 --- /dev/null +++ b/src/family/components/MetricCard.tsx @@ -0,0 +1,69 @@ +import React from 'react'; +import { LucideIcon } from 'lucide-react'; + +interface MetricCardProps { + title: string; + value: string | number; + subtitle?: string; + icon: LucideIcon; + trend?: 'up' | 'down' | 'neutral'; + trendValue?: string; + color?: 'blue' | 'green' | 'yellow' | 'red'; + onClick?: () => void; +} + +/** + * 指标卡片组件 + * 用于 Dashboard 展示关键数据 + */ +export const MetricCard: React.FC = ({ + title, + value, + subtitle, + icon: Icon, + trend, + trendValue, + color = 'blue', + onClick, +}) => { + const colorClasses = { + 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', + }; + + const trendColors = { + up: 'text-green-600', + down: 'text-red-600', + neutral: 'text-gray-600', + }; + + return ( +
+
+
+

{title}

+

{value}

+ {subtitle && ( +

{subtitle}

+ )} + {trend && trendValue && ( +

+ {trend === 'up' ? '↑' : trend === 'down' ? '↓' : '→'} {trendValue} +

+ )} +
+
+ +
+
+
+ ); +};