/** * KPI Card Component * Displays key performance indicators with trend indicators */ import { TrendDirection } from '../../lib/analytics/types'; interface KPICardProps { title: string; value: number | string; unit?: string; change?: number; changePercent?: number; trend?: TrendDirection; color?: 'green' | 'blue' | 'purple' | 'orange' | 'red' | 'teal'; icon?: React.ReactNode; loading?: boolean; } const colorClasses = { green: { bg: 'bg-green-50', text: 'text-green-600', icon: 'text-green-500', }, blue: { bg: 'bg-blue-50', text: 'text-blue-600', icon: 'text-blue-500', }, purple: { bg: 'bg-purple-50', text: 'text-purple-600', icon: 'text-purple-500', }, orange: { bg: 'bg-orange-50', text: 'text-orange-600', icon: 'text-orange-500', }, red: { bg: 'bg-red-50', text: 'text-red-600', icon: 'text-red-500', }, teal: { bg: 'bg-teal-50', text: 'text-teal-600', icon: 'text-teal-500', }, }; export default function KPICard({ title, value, unit, change, changePercent, trend = 'stable', color = 'green', icon, loading = false, }: KPICardProps) { const classes = colorClasses[color]; const getTrendIcon = () => { if (trend === 'up') { return ( ); } if (trend === 'down') { return ( ); } return ( ); }; const getTrendColor = () => { if (trend === 'up') return 'text-green-600'; if (trend === 'down') return 'text-red-600'; return 'text-gray-500'; }; if (loading) { return (
{title}
{icon && {icon}}{value}
{unit && {unit}}