/** * InsightCard: 指标洞察卡片 —— 数值 + 趋势 + 对比。 * * 灵感来自 beautifului InsightCard / StatCard,适配 Profeto 报纸风: * - 大字号主指标(衬线) * - 趋势箭头(↑↓) + 变化率 * - 可选对比基线(如"较上周 +12%") * - 状态色(info/warning/positive/negative) */ import { TrendingArrow } from './TrendingArrow' export interface InsightCardProps { label: string value: string | number /** 趋势方向: up/down/flat */ trend?: 'up' | 'down' | 'flat' /** 变化率文案,如 "+12%" */ trendLabel?: string /** 对比说明,如 "较昨日" */ compareHint?: string /** 状态色 */ status?: 'info' | 'warning' | 'positive' | 'negative' /** 副标题 / 补充说明 */ subtitle?: string /** 图标(ReactNode) */ icon?: React.ReactNode } const STATUS_STYLE: Record = { info: { card: 'border-ink-200', accent: 'text-ink-600' }, warning: { card: 'border-amber-300', accent: 'text-amber-700' }, positive: { card: 'border-emerald-300', accent: 'text-emerald-700' }, negative: { card: 'border-rose-300', accent: 'text-rose-700' }, } const TREND_COLOR: Record = { up: 'text-emerald-600', down: 'text-rose-600', flat: 'text-ink-400', } export function InsightCard({ label, value, trend, trendLabel, compareHint, status = 'info', subtitle, icon }: InsightCardProps) { const style = STATUS_STYLE[status] return (

{label}

{value}

{subtitle && (

{subtitle}

)}
{icon && (
{icon}
)}
{(trend || trendLabel) && (
{trend && } {trendLabel && ( {trendLabel} )} {compareHint && {compareHint}}
)}
) } /** InsightCard 网格容器 */ export function InsightGrid({ children }: { children: React.ReactNode }) { return (
{children}
) }