import { Card } from "@/components/ui/card"; import { cn } from "@/lib/utils"; import { Sparkline } from "./Sparkline"; /** * KPI card: a label, a big tabular value, an optional ▲/▼ delta chip (colored * by sign) and an optional inline sparkline. Built on the shadcn Card with a * subtle hover lift. `delta` is a signed percentage-style number (e.g. 12, -4). */ export function TrendStat({ label, value, delta, data, hint, className, }: { label: string; value: string; delta?: number; data?: number[]; hint?: string; className?: string; }) { const hasDelta = typeof delta === "number" && Number.isFinite(delta); const up = hasDelta && delta! >= 0; return (
{label} {hasDelta && ( {up ? "▲" : "▼"} {Math.abs(delta!)}% )}
{value}
{hint ? (
{hint}
) : null} {data && data.length > 0 ? (
) : null}
); }