import { ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons' import './StatCard.css' import { ReactNode } from 'react' export interface StatCardProps { title: string value: number | string icon?: ReactNode color?: string trend?: { value: number; direction: 'up' | 'down' } suffix?: string layout?: 'column' | 'row' gridColumn?: string className?: string onClick?: () => void style?: React.CSSProperties } /** * 统计卡片组件 */ function StatCard({ title, value, icon, color = 'blue', trend, suffix = '', layout = 'column', gridColumn, className = '', onClick, style: customStyle = {}, }: StatCardProps) { const colorMap: Record = { blue: '#1677ff', green: '#52c41a', orange: '#faad14', red: '#ff4d4f', purple: '#722ed1', gray: '#8c8c8c', } const themeColor = colorMap[color] || color const style = { ...(gridColumn ? { gridColumn } : {}), ...customStyle, } return (
{title} {icon && ( {icon} )}
{value} {suffix && {suffix}}
{trend && (
{trend.direction === 'up' ? : } {Math.abs(trend.value)}%
)}
) } export default StatCard