import { Component, createMemo } from 'solid-js'; export interface ProgressRingProps { /** 0..1 fraction. */ progress: () => number; /** Diameter in px. Default 32. */ size?: number; /** Stroke color. Default --accent. */ color?: string; /** Stroke width. Default size/10. */ strokeWidth?: number; /** Show numeric percent in middle. */ showLabel?: boolean; ariaLabel?: string; } export const ProgressRing: Component = (props) => { const size = () => props.size ?? 32; const strokeWidth = () => props.strokeWidth ?? Math.max(2, Math.round(size() / 10)); const radius = () => (size() - strokeWidth()) / 2; const circumference = () => 2 * Math.PI * radius(); const progress = () => Math.max(0, Math.min(1, props.progress())); const offset = createMemo(() => circumference() * (1 - progress())); const color = () => props.color ?? 'var(--accent)'; return ( {props.showLabel && ( {Math.round(progress() * 100)} )} ); };