All files / src/components/analytics StatCard.tsx

100% Statements 1/1
100% Branches 3/3
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46                                            637x                                              
import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
import type { LucideIcon } from "lucide-react";
 
interface StatCardProps {
	name: string;
	value: number;
	subtext: string;
	icon: LucideIcon;
	color: string;
	bgColor: string;
	isLoading?: boolean;
}
 
export function StatCard({
	name,
	value,
	subtext,
	icon: Icon,
	color,
	bgColor,
	isLoading = false,
}: StatCardProps) {
	return (
		<Card>
			<CardHeader className="flex flex-row items-center justify-between p-3 pb-1 sm:p-5 sm:pb-2">
				<CardTitle className="text-xs sm:text-sm font-medium text-foreground-muted">
					{name}
				</CardTitle>
				<div className={`p-1.5 sm:p-2 rounded-lg ${bgColor}`}>
					<Icon className={`h-4 w-4 sm:h-5 sm:w-5 ${color}`} />
				</div>
			</CardHeader>
			<CardContent className="p-3 pt-0 sm:p-5 sm:pt-0">
				<div className="text-xl sm:text-2xl font-bold">
					{isLoading ? (
						<div className="h-8 w-16 bg-background-muted rounded animate-pulse" />
					) : (
						value.toLocaleString()
					)}
				</div>
				<p className="text-xs text-foreground-muted mt-1">{subtext}</p>
			</CardContent>
		</Card>
	);
}