File size: 1,733 Bytes
b4e31eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56

import React from 'react';

interface StatusBarProps {
  label: string;
  value: number;
  maxValue: number;
  color: string;
  icon: string;
}

const StatusBar: React.FC<StatusBarProps> = ({ label, value, maxValue, color, icon }) => {
  const percentage = (value / maxValue) * 100;
  
  const getBarColor = () => {
    if (percentage >= 70) return color;
    if (percentage >= 40) return '#FDE68A';
    return '#FECACA';
  };

  return (
    <div className="bg-white/80 backdrop-blur-sm rounded-2xl p-4 shadow-lg hover:shadow-xl transition-all duration-300">
      <div className="flex items-center justify-between mb-2">
        <span className="text-sm font-medium text-gray-700 flex items-center gap-2">
          <span className="text-lg">{icon}</span>
          {label.replace(/^[^\s]+\s/, '')}
        </span>
        <span className="text-sm font-bold text-gray-800">{value}/{maxValue}</span>
      </div>
      
      <div className="w-full bg-gray-200 rounded-full h-3 overflow-hidden">
        <div 
          className="h-full rounded-full transition-all duration-1000 ease-out shadow-inner"
          style={{ 
            width: `${percentage}%`,
            backgroundColor: getBarColor(),
            background: `linear-gradient(90deg, ${getBarColor()}, ${getBarColor()}dd)`
          }}
        >
          {percentage > 10 && (
            <div className="w-full h-full bg-gradient-to-r from-white/20 to-transparent rounded-full"></div>
          )}
        </div>
      </div>
      
      {percentage < 30 && (
        <div className="mt-1 text-xs text-red-500 font-medium animate-pulse">
          ⚠️ Low {label.split(' ')[1] || label}
        </div>
      )}
    </div>
  );
};

export default StatusBar;