import { Card, CardContent, CardHeader, CardTitle, } from "@bullstudio/ui/components/card"; import { ChartContainer } from "@bullstudio/ui/components/chart"; import { Area, AreaChart } from "recharts"; import { cn } from "@bullstudio/ui/lib/utils"; import { TrendingUp, TrendingDown, Minus } from "lucide-react"; type MetricCardProps = { title: string; value: string | number; subtitle?: string; sparklineData?: { value: number }[]; sparklineColor?: string; trend?: { value: number; direction: "up" | "down" | "neutral"; isPositive?: boolean; }; icon?: React.ReactNode; }; export function MetricCard({ title, value, subtitle, sparklineData, sparklineColor = "hsl(var(--chart-1))", trend, icon, }: MetricCardProps) { const TrendIcon = trend?.direction === "up" ? TrendingUp : trend?.direction === "down" ? TrendingDown : Minus; const trendColorClass = trend?.direction === "neutral" ? "text-zinc-500" : trend?.isPositive ? "text-emerald-500" : "text-red-500"; const gradientId = `gradient-${title.replace(/\s+/g, "-")}`; return ( {icon} {title}
{value}
{subtitle && (
{subtitle}
)}
{trend && trend.direction !== "neutral" && (
{trend.value}%
)}
{sparklineData && sparklineData.length > 0 && (
)}
); }