import cx from 'classnames'; import { IProgressInstanceProps } from '../types'; import { DEFAULT_WIDTH } from '../constants'; import AnimatedArc from './AnimatedArc'; import ProgressInfo from './ProgressInfo'; const CircleProgress: React.FC = props => { const { percent, showInfo, format, strokeWidth, width, bgColor, color, state, strokeLinecap, } = props; const progressWidth = width || DEFAULT_WIDTH.CIRCLE; const mid = progressWidth / 2; const diameter = progressWidth - strokeWidth; const radius = diameter / 2; const circumference = diameter * Math.PI; const offset = (circumference * (100 - percent)) / 100; return (
{/* This g element fixes https://github.com/youzan/zent/issues/1209 With Safari: 1. We can't rotate on the circle, it breaks when zoom in/out 2. transform-origin with a value of `center` or `50%` won't work So we rotate on the g with absolute origin values */} {state === 'normal' && ( )} {showInfo && (
)}
); }; export default CircleProgress;