31 lines
1.1 KiB
TypeScript
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>
|
|
)
|
|
}
|