Skip to content

Commit

Permalink
feat:add circular progress svg component
Browse files Browse the repository at this point in the history
  • Loading branch information
maceteligolden committed Nov 27, 2023
1 parent 48c8d80 commit 92c53ad
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions apps/web/components/ui/svgs/circular-progress.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export default function CircularProgress({
radius=24,
cx=24,
cy=24,
percentage=55
}: {
radius?: number,
cx?: number,
cy?: number,
percentage: number
}) {
const circumference = radius * 2 * Math.PI;

return (
<>
<div
x-data="scrollProgress"
className="relative -rotate-90 inline-flex items-center justify-center overflow-hidden rounded-full"
>

<svg className="w-12 h-12">
<circle
className="text-gray-300"
strokeWidth="8"
stroke="currentColor"
fill="transparent"
r={radius}
cx={cx}
cy={cy}
/>
<circle
className="text-[#27AE60]"
strokeWidth="8"
strokeDasharray={circumference}
strokeDashoffset={`calc(${circumference} - ${percentage / 100 * circumference})`}
strokeLinecap="round"
stroke="currentColor"
fill="transparent"
r={radius}
cx={cx}
cy={cy}
/>
</svg>
<span className="absolute text-xs font-normal text-black dark:text-white rotate-90" x-text={`${percentage}%`}>
{percentage}H
</span>
</div>
</>
)
}

0 comments on commit 92c53ad

Please sign in to comment.