"use client"; type EbookProgressRingProps = { total: number; completed: number; label?: string; size?: number; }; export function EbookProgressRing({ total, completed, label, size = 96, }: EbookProgressRingProps) { const radius = (size - 12) / 2; const circumference = 2 * Math.PI * radius; const pct = total > 0 ? completed / total : 0; const strokeDashoffset = circumference * (1 - pct); const displayPct = Math.round(pct * 100); return (
{/* Track */} {/* Progress */} {/* Center text — counter-rotate so it reads normally */} {displayPct}% {label && ( {label} )} {total > 0 && ( {completed}/{total} )}
); }