* chore: format all files in the project * fix: removing @types/react from dependencies * fix: adding prettier and eslint config * chore: format files * fix: upgrading turbo version * chore: ignoring warnings and adding todos * fix: updated the type of bubble menu item in the document editor * chore: format files --------- Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import React, { useState, useEffect, FC } from "react";
|
|
|
|
interface IRadialProgressBar {
|
|
progress: number;
|
|
}
|
|
|
|
export const RadialProgressBar: FC<IRadialProgressBar> = (props) => {
|
|
const { progress } = props;
|
|
const [circumference, setCircumference] = useState(0);
|
|
|
|
useEffect(() => {
|
|
const radius = 40;
|
|
const circumference = 2 * Math.PI * radius;
|
|
setCircumference(circumference);
|
|
}, []);
|
|
|
|
const progressOffset = ((100 - progress) / 100) * circumference;
|
|
|
|
return (
|
|
<div className="relative h-4 w-4">
|
|
<svg className="absolute left-0 top-0" viewBox="0 0 100 100">
|
|
<circle
|
|
className={"stroke-current opacity-10"}
|
|
cx="50"
|
|
cy="50"
|
|
r="40"
|
|
strokeWidth="12"
|
|
fill="none"
|
|
strokeDasharray={`${circumference} ${circumference}`}
|
|
/>
|
|
<circle
|
|
className={`stroke-current`}
|
|
cx="50"
|
|
cy="50"
|
|
r="40"
|
|
strokeWidth="12"
|
|
fill="none"
|
|
strokeDasharray={`${circumference} ${circumference}`}
|
|
strokeDashoffset={progressOffset}
|
|
transform="rotate(-90 50 50)"
|
|
/>
|
|
</svg>
|
|
</div>
|
|
);
|
|
};
|