import { Card } from 'antd' import type { CSSProperties, ReactNode } from 'react' type Color = 'blue' | 'green' | 'orange' | 'purple' | 'red' const colorMap: Record = { blue: { bg: '#e6f4ff', color: '#1677ff' }, green: { bg: '#f6ffed', color: '#52c41a' }, orange: { bg: '#fff7e6', color: '#fa8c16' }, purple: { bg: '#f9f0ff', color: '#722ed1' }, red: { bg: '#fff1f0', color: '#ff4d4f' }, } interface StatCardProps { icon: ReactNode color?: Color title: string value: number | string suffix?: string precision?: number valueStyle?: CSSProperties subText?: string } export default function StatCard({ icon, color = 'blue', title, value, suffix, precision, valueStyle, subText }: StatCardProps) { const c = colorMap[color] const display = typeof value === 'number' && precision != null ? value.toFixed(precision) : value return (
{icon}
{title}
{display} {suffix && {suffix}}
{subText ?? ''}
) }