import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Progress } from '@/components/ui/progress'; import { LucideIcon } from 'lucide-react'; import { cn } from '@/lib/utils'; // Assuming you have a utility for className import { motion } from 'framer-motion'; // For smooth transitions interface MetricDisplayCardProps { title: string; value: number | string | null; unit?: string; icon: LucideIcon; percentage?: number | null; // Optional percentage for the progress bar } const MetricDisplayCard: React.FC = ({ title, value, unit, icon: Icon, // Renamed to Icon to be used as a component percentage, }) => { const isPercentage = percentage !== undefined && percentage !== null; return ( {/* Optional: Add a subtle background element for techy feel */}
{title} {isPercentage ? ( <>
{value !== null ? (typeof value === 'number' ? value.toFixed(1) : value) : '--'}{unit}

{title} usage

{percentage !== null && (
80 ? 'bg-destructive' : percentage > 50 ? 'bg-warning' : 'bg-primary' // Example color logic based on percentage )} initial={{ width: 0 }} animate={{ width: `${percentage}%` }} transition={{ duration: 0.5, ease: "easeOut" }} />
)} ) : ( <>
{value !== null ? (typeof value === 'number' ? value.toFixed(1) : value) : '--'}{unit}

Current {title.toLowerCase()}

)}
); }; export default MetricDisplayCard;