import type { ReactNode } from "react"; import ArrowDownIcon from "@/assets/icons/arrow-down.svg?react"; import ArrowUpIcon from "@/assets/icons/arrow-up.svg?react"; import MinusIcon from "@/assets/icons/minus.svg?react"; export type MetricCardProps = { label: string; value: string | number; subtext?: string; icon?: ReactNode; trend?: "up" | "down" | "neutral"; }; const trendConfig = { up: { Icon: ArrowUpIcon, className: "text-violet-600" }, down: { Icon: ArrowDownIcon, className: "text-[var(--color-status-critical-text)]" }, neutral: { Icon: MinusIcon, className: "text-neutral-60" }, } as const; export function MetricCard({ label, value, subtext, icon, trend }: MetricCardProps) { const TrendGlyph = trend ? trendConfig[trend].Icon : null; const trendColor = trend ? trendConfig[trend].className : ""; return (
{icon ?
{icon}
: null}

{label}

{value} {trend && TrendGlyph ? ( ) : null}
{subtext ?

{subtext}

: null}
); }