"use client" import { useEffect, useState } from "react" import { cn } from "@/lib/utils" const RADIUS = 26 const STROKE_WIDTH = 3 const CIRCUMFERENCE = 2 * Math.PI * RADIUS type SpectrumColor = "indigo" | "violet" | "cyan" | "emerald" | "amber" const spectrum: Record = { indigo: { stroke: "#818CF8", glow: "rgba(129,140,248,0.5)", textClass: "text-indigo-300", bgClass: "bg-indigo-500/12", glowRgba: "rgba(99,102,241,0.4)", borderHover: "99,102,241" }, violet: { stroke: "#A78BFA", glow: "rgba(167,139,250,0.5)", textClass: "text-violet-300", bgClass: "bg-violet-500/12", glowRgba: "rgba(139,92,246,0.4)", borderHover: "139,92,246" }, cyan: { stroke: "#22D3EE", glow: "rgba(34,211,238,0.45)", textClass: "text-cyan-300", bgClass: "bg-cyan-500/12", glowRgba: "rgba(6,182,212,0.35)", borderHover: "6,182,212" }, emerald: { stroke: "#34D399", glow: "rgba(52,211,153,0.45)", textClass: "text-emerald-300", bgClass: "bg-emerald-500/12", glowRgba: "rgba(16,185,129,0.35)", borderHover: "16,185,129" }, amber: { stroke: "#FBBF24", glow: "rgba(251,191,36,0.45)", textClass: "text-amber-300", bgClass: "bg-amber-500/12", glowRgba: "rgba(245,158,11,0.35)", borderHover: "245,158,11" }, } interface StatRingProps { value: string | number label: string icon: React.ElementType color?: SpectrumColor fillPercent?: number sub?: string delay?: number } export function StatRing({ value, label, icon: Icon, color = "indigo", fillPercent = 0, sub, delay = 0, }: StatRingProps) { const [mounted, setMounted] = useState(false) const [visible, setVisible] = useState(false) const c = spectrum[color] const clampedFill = Math.min(Math.max(fillPercent, 0), 100) const targetOffset = CIRCUMFERENCE - (clampedFill / 100) * CIRCUMFERENCE useEffect(() => { setMounted(true) const t = setTimeout(() => setVisible(true), delay) return () => clearTimeout(t) }, [delay]) return (
{ e.currentTarget.style.borderColor = `rgba(${c.borderHover},0.35)` e.currentTarget.style.transform = "translateY(-2px)" e.currentTarget.style.boxShadow = `0 12px 40px rgba(0,0,0,0.4), 0 0 24px -8px ${c.glowRgba}, inset 0 1px 0 rgba(255,255,255,0.08)` }} onMouseLeave={(e) => { e.currentTarget.style.borderColor = "rgba(255,255,255,0.07)" e.currentTarget.style.transform = "translateY(0)" e.currentTarget.style.boxShadow = "0 4px 20px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.06)" }} > {/* Corner glow */}
{/* SVG ring with icon inside */}
{/* Track */} {/* Fill arc */} {/* Icon centered in ring */}
{/* Value */}

{value}

{/* Label + sub */}

{label}

{sub && (

{sub}

)}
) }