-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:add circular progress svg component
- Loading branch information
1 parent
48c8d80
commit 92c53ad
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
</> | ||
) | ||
} |