From 294222820826c66854fc688dcc5cc14bbb504b3f Mon Sep 17 00:00:00 2001 From: Tanmoy Basak Anjan Date: Wed, 23 Feb 2022 06:17:35 +0600 Subject: [PATCH] progress calculations (#1963) Co-authored-by: Michael Yankelev <12774278+FSM1@users.noreply.github.com> --- .../src/ProgressBar/CircularProgressBar.tsx | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/packages/common-components/src/ProgressBar/CircularProgressBar.tsx b/packages/common-components/src/ProgressBar/CircularProgressBar.tsx index b9e80f2407..5f43bc4480 100644 --- a/packages/common-components/src/ProgressBar/CircularProgressBar.tsx +++ b/packages/common-components/src/ProgressBar/CircularProgressBar.tsx @@ -29,8 +29,7 @@ const useStyles = makeStyles((theme: ITheme) => } }, progressBar: (props: IStyleProps) => ({ - strokeLinecap: "round", - strokeDasharray: `${props.circumference}px ${props.circumference}px`, + strokeDasharray: `${props.circumference}px`, strokeDashoffset: `${ ((100 - props.progress) / 100) * props.circumference }px`, @@ -95,18 +94,16 @@ const CircularProgressBar: React.FC = ({ label }) => { const strokeWidth = size === "small" ? 2 : size === "medium" ? 3 : 4 - const radius = width - const finalRadius = radius - strokeWidth - const finalWidth = finalRadius + strokeWidth + const finalRadius = width - strokeWidth const pathDescription = ` - M ${finalWidth},${finalWidth} m 0,-${finalRadius} + M ${finalRadius},${finalRadius} m 0,-${finalRadius} a ${finalRadius},${finalRadius} 0 1 1 0,${2 * finalRadius} a ${finalRadius},${finalRadius} 0 1 1 0,-${2 * finalRadius} ` - const diameter = 2 * radius - const circumference = Math.PI * 2 * radius + const circumference = Math.PI * 2 * finalRadius const progressValue = progress < 0 ? 0 : progress > 100 ? 100 : progress + const totalWidth = width * 2 const classes = useStyles({ progress: progressValue, @@ -118,25 +115,27 @@ const CircularProgressBar: React.FC = ({ {label && {label}} - {showBackdrop && ( + + {showBackdrop && ( + + )} + - )} - - + )