import { Component, createMemo } from "solid-js" interface ProgressCircleProps { percentage: number size?: number strokeWidth?: number } export const ProgressCircle: Component = (props) => { // --- Set default values for props --- const size = () => props.size || 16 const strokeWidth = () => props.strokeWidth || 3 // --- Constants for SVG calculation --- const viewBoxSize = 16 const center = viewBoxSize / 2 const radius = () => center - strokeWidth() / 2 const circumference = createMemo(() => 2 * Math.PI * radius()) // --- Reactive Calculation for the progress offset --- const offset = createMemo(() => { const clampedPercentage = Math.max(0, Math.min(100, props.percentage || 0)) const progress = clampedPercentage / 100 return circumference() * (1 - progress) }) return ( ) }