import styled, { useTheme } from "styled-components"; const cleanPercentage = (percentage: number) => { const tooLow = !Number.isFinite(+percentage) || percentage < 0; const tooHigh = percentage > 100; return tooLow ? 0 : tooHigh ? 100 : +percentage; }; const Circle = ({ color, percentage, offset, }: { color: string; percentage?: number; offset: number; }) => { const radius = offset * 0.7; const circumference = 2 * Math.PI * radius; let strokeDashoffset = 0; if (percentage !== undefined) { // because the circle is so small, anything greater than 85% appears like 100% const visible = percentage > 85 && percentage < 100 ? 85 : percentage; strokeDashoffset = ((100 - visible) * circumference) / 100; } return ( ); }; /** * Renders a small circular progress indicator. * * @param percentage - the progress to display, clamped to the range 0–100. * @param size - the width and height of the indicator in pixels. * @param label - an accessible name announced by assistive technology. * @returns the rendered progress bar element. */ const CircularProgressBar = ({ percentage, size = 16, label, }: { percentage: number; size?: number; label?: string; }) => { const theme = useTheme(); percentage = cleanPercentage(percentage); const offset = Math.floor(size / 2); return ( ); }; const SVG = styled.svg` flex-shrink: 0; `; export default CircularProgressBar;