Pierre Wessman a1c3c2f43c dashboard v1
2025-12-12 10:46:15 +01:00

31 lines
1.1 KiB
TypeScript

import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { TrendingUp, TrendingDown } from "lucide-react"
import type { MetricCard as MetricCardType } from "@/types/dashboard"
export function MetricCard({ title, value, change, changeLabel }: MetricCardType) {
const isPositive = change >= 0
return (
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">{title}</CardTitle>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{value}</div>
<div className="flex items-center text-xs text-muted-foreground mt-1">
{isPositive ? (
<TrendingUp className="mr-1 h-4 w-4 text-green-500" />
) : (
<TrendingDown className="mr-1 h-4 w-4 text-red-500" />
)}
<span className={isPositive ? "text-green-500" : "text-red-500"}>
{isPositive ? "+" : ""}
{change}%
</span>
<span className="ml-1">{changeLabel}</span>
</div>
</CardContent>
</Card>
)
}