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} +

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