File size: 1,274 Bytes
7c447a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// src/components/MetricCard.tsx
import React from 'react';
import type { ReactNode } from 'react';
import { TrendingDown, TrendingUp } from 'lucide-react';

export default function MetricCard({
  title, value, change, positive, icon, description
}: {
  title: string; value: string; change?: string; positive?: boolean; icon: ReactNode; description?: string;
}) {
  return (
    <div className="bg-white rounded-lg shadow-sm border p-6 hover:shadow-md transition-shadow">
      <div className="flex items-center justify-between">
        <div className="flex-1">
          <p className="text-sm font-medium text-gray-600">{title}</p>
          <p className="text-2xl font-bold text-gray-900 mt-1">{value}</p>
          {change && (
            <div className="flex items-center mt-2">
              {positive ? <TrendingDown className="w-4 h-4 text-green-500 mr-1" /> : <TrendingUp className="w-4 h-4 text-red-500 mr-1" />}
              <span className={`text-sm font-medium ${positive ? 'text-green-600' : 'text-red-600'}`}>{change}</span>
            </div>
          )}
          {description && <p className="text-xs text-gray-500 mt-1">{description}</p>}
        </div>
        <div className="p-3 bg-blue-50 rounded-full">{icon}</div>
      </div>
    </div>
  );
}