import { type Component, For } from "solid-js"; import { CheckCircle2 } from "lucide-solid"; import { cn } from "@/lib/utils"; interface StatusCircleProps { status: number; size?: number; className?: string; recurrenceProgress?: number | null; } export const StatusCircle: Component = (props) => { const size = () => props.size || 24; const radius = () => (size() / 2) - 2; // Subtract stroke width/padding const circumference = () => 2 * Math.PI * radius(); // Status 0: Empty Circle // Status 10: CheckCircle2 (Green) // Status 1-9: Progress Ring const strokeDashoffset = () => { // Invert to fill clockwise? // Progress 1-9. // 1 = 10%, 9 = 90% const percentage = Math.max(0, Math.min(10, props.status)) / 10; return circumference() * (1 - percentage); }; const dotCount = () => 12; const dotRadius = () => Math.max(1.4, size() * 0.06); const dotRingRadius = () => radius() - 1; const filledDots = () => { const progress = props.recurrenceProgress ?? 0; return Math.floor(Math.max(0, Math.min(1, progress)) * dotCount()); }; return (
{props.status >= 10 ? ( props.recurrenceProgress != null ? ( {(_, index) => { const angle = (index() / dotCount()) * Math.PI * 2 - Math.PI / 2; const cx = size() / 2 + Math.cos(angle) * dotRingRadius(); const cy = size() / 2 + Math.sin(angle) * dotRingRadius(); const isFilled = index() < filledDots(); return ( ); }} ) : ( ) ) : ( // Progress Circle
{/* Background Circle (Ghost) */} {/* Progress Arc */} {/* Hover indicator (maybe show check on hover?) User didn't ask for generic hover, just visual update. */}
)}
); };