From 236065f282d1e85a88954e42941e126beb341ceb Mon Sep 17 00:00:00 2001 From: Felix Mosheev <9304194+felixmosh@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:37:58 +0300 Subject: [PATCH] feat: improve progress bar svg based on https://x.com/devongovett/status/1835692034104918053/photo/1 --- .../JobCard/Progress/Progress.module.css | 5 +-- .../components/JobCard/Progress/Progress.tsx | 33 ++++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/ui/src/components/JobCard/Progress/Progress.module.css b/packages/ui/src/components/JobCard/Progress/Progress.module.css index 4176d082..60bb4da5 100644 --- a/packages/ui/src/components/JobCard/Progress/Progress.module.css +++ b/packages/ui/src/components/JobCard/Progress/Progress.module.css @@ -4,15 +4,12 @@ } .progress circle { - transform-origin: center; transition: stroke-dashoffset 500ms ease-in-out; fill: none; - stroke-width: 8; - stroke-linecap: butt; } .progress text { - font-size: 2.5rem; + font-size: 1.5rem; font-family: inherit; font-weight: 300; fill: #a0aec0; diff --git a/packages/ui/src/components/JobCard/Progress/Progress.tsx b/packages/ui/src/components/JobCard/Progress/Progress.tsx index fdeb78da..fc18d785 100644 --- a/packages/ui/src/components/JobCard/Progress/Progress.tsx +++ b/packages/ui/src/components/JobCard/Progress/Progress.tsx @@ -4,32 +4,35 @@ import cn from 'clsx'; import { Status } from '@bull-board/api/typings/app'; import { STATUSES } from '@bull-board/api/src/constants/statuses'; -const radius = 65; -const circumference = 2 * Math.PI * radius; - interface ProgressProps { percentage: number; + strokeWidth?: number; status: Status; className?: string; } -export const Progress = ({ percentage, status, className }: ProgressProps) => { - const circleProps = { - cx: 70, - cy: 70, - r: radius, +export const Progress = ({ percentage, status, className, strokeWidth = 6 }: ProgressProps) => { + const commonProps = { + cx: '50%', + cy: '50%', + r: `calc(50% - ${strokeWidth / 2}px)`, + strokeWidth, + ['transform-origin']: 'center', }; return ( - - + + - + {Math.round(percentage)}%