import * as React from 'react'; import { cn } from '@/lib/utils'; interface KPITileProps extends React.HTMLAttributes { title: string; value: React.ReactNode; /** Signed delta vs. prior period; positive = green, negative = red, undefined = no chip. */ delta?: number; /** Pre-rendered sparkline (recharts) — caller decides shape. */ sparkline?: React.ReactNode; /** Optional accent stripe colour token; defaults to brand. */ accent?: 'brand' | 'success' | 'warning' | 'mint' | 'teal' | 'purple'; } const ACCENT_STRIPES: Record, string> = { brand: 'bg-gradient-brand', success: 'bg-success', warning: 'bg-warning', mint: 'bg-mint', teal: 'bg-teal', purple: 'bg-purple', }; export function KPITile({ title, value, delta, sparkline, accent = 'brand', className, ...props }: KPITileProps) { const deltaClass = typeof delta === 'number' ? delta > 0 ? 'text-success' : delta < 0 ? 'text-error' : 'text-muted-foreground' : ''; const deltaPrefix = typeof delta === 'number' ? (delta > 0 ? '+' : '') : ''; return (
{title}
{value}
{typeof delta === 'number' ? (
{deltaPrefix} {delta}
) : null}
{sparkline ?
{sparkline}
: null}
); }