import React from "react"; interface CircleProgressProps { value: number; maxValue?: number; size?: number; strokeWidth?: number; className?: string; showPercentage?: boolean; color?: string; } export const CircleProgress: React.FC = ({ value, maxValue = 100, size = 40, strokeWidth = 4, className = "", showPercentage = true, color = "", }) => { const percentage = Math.min(100, Math.max(0, (value / maxValue) * 100)); const radius = size / 2 - strokeWidth / 2; const circumference = radius * 2 * Math.PI; const strokeDashoffset = circumference - (percentage / 100) * circumference; const getColor = () => { if (color) return color; if (percentage > 90) return "stroke-red-600"; if (percentage > 50) return "stroke-yellow-400"; return "stroke-green-500"; }; return (
{/* Background circle */} {/* Progress circle */} {showPercentage && (
{percentage.toFixed(0)}%
)}
); };