/** * This progress ring is like a progress bar (``), but circular. * Like ``, it has a `value` prop and a `max` prop. The `value` * prop is the current progress, and the `max` prop is the maximum progress. * The `value` prop can be any number between 0 and `max`, inclusive. * The `max` prop can be any number greater than 0, and defaults to 1. * Indeterminate progress is not supported. * The required `sizePx` prop is the outer diameter of the ring, in pixels. * The optional `strokeWidthPx` prop is the width of the ring, in pixels. */ import PropTypes from 'prop-types'; import React from 'react'; import classNames from 'classnames'; import styles from './progress-ring.css'; const ProgressRingComponent = ({ className, max = 1, sizePx, strokeWidthPx, value, ...props }) => { if (typeof strokeWidthPx === 'undefined') { strokeWidthPx = sizePx / 6; } const center = sizePx / 2; const diameter = (sizePx - strokeWidthPx); const radius = diameter / 2; const circumference = Math.PI * diameter; const offset = circumference * (1 - (value / max)); const ringSvgProps = { cx: center, cy: center, r: radius }; return (