2026-06-01 23:35:00 +08:00
|
|
|
import React from 'react'
|
2026-06-19 19:44:35 +08:00
|
|
|
import { cn } from '@/ui/lib/utils'
|
2026-05-19 16:05:09 +08:00
|
|
|
|
|
|
|
|
interface ProgressCircleProps {
|
2026-06-01 23:35:00 +08:00
|
|
|
progress: number
|
|
|
|
|
className?: string
|
2026-05-19 16:05:09 +08:00
|
|
|
}
|
|
|
|
|
|
2026-06-01 23:35:00 +08:00
|
|
|
export const ProgressCircle: React.FC<ProgressCircleProps> = ({ progress, className }) => {
|
|
|
|
|
const radius = 20
|
|
|
|
|
const circumference = 2 * Math.PI * radius
|
2026-06-19 19:44:35 +08:00
|
|
|
const offset = circumference - (Math.min(100, Math.max(0, progress)) / 100) * circumference
|
2026-05-19 16:05:09 +08:00
|
|
|
|
|
|
|
|
return (
|
2026-06-19 19:44:35 +08:00
|
|
|
<svg viewBox="0 0 50 50" className={cn('w-12 h-12', className)}>
|
2026-05-19 16:05:09 +08:00
|
|
|
<circle
|
|
|
|
|
cx="25"
|
|
|
|
|
cy="25"
|
|
|
|
|
r={radius}
|
2026-06-19 19:44:35 +08:00
|
|
|
className="stroke-muted"
|
2026-05-19 16:05:09 +08:00
|
|
|
strokeWidth="4"
|
|
|
|
|
fill="transparent"
|
|
|
|
|
/>
|
|
|
|
|
<circle
|
|
|
|
|
cx="25"
|
|
|
|
|
cy="25"
|
|
|
|
|
r={radius}
|
2026-06-19 19:44:35 +08:00
|
|
|
className="stroke-primary transition-all duration-300 ease-out"
|
2026-05-19 16:05:09 +08:00
|
|
|
strokeWidth="4"
|
|
|
|
|
fill="transparent"
|
|
|
|
|
strokeDasharray={circumference}
|
|
|
|
|
strokeDashoffset={offset}
|
|
|
|
|
transform="rotate(-90 25 25)"
|
|
|
|
|
/>
|
|
|
|
|
<text
|
|
|
|
|
x="50%"
|
|
|
|
|
y="50%"
|
|
|
|
|
textAnchor="middle"
|
|
|
|
|
dy=".3em"
|
2026-06-19 19:44:35 +08:00
|
|
|
className="fill-foreground text-[10px] font-bold"
|
2026-05-19 16:05:09 +08:00
|
|
|
>
|
|
|
|
|
{`${Math.round(progress)}%`}
|
|
|
|
|
</text>
|
|
|
|
|
</svg>
|
2026-06-01 23:35:00 +08:00
|
|
|
)
|
|
|
|
|
}
|