'use client' import { cn } from '@/lib/utils' import React from 'react' type RootProps = React.ComponentPropsWithoutRef<'div'> & { size?: 'sm' | 'md' | 'lg' children?: React.ReactNode } const Root = React.forwardRef, RootProps>( ({ size = 'md', children, className, ...props }, ref) => { const sizeClasses = { sm: 'w-16 h-16 text-sm', md: 'w-20 h-20 text-base', lg: 'w-24 h-24 text-xl', } return (
{children}
) }, ) const Label = React.forwardRef< React.ElementRef<'div'>, React.ComponentPropsWithoutRef<'div'> & { value: number; suffix?: string } >(({ className, children, value, suffix, ...props }, ref) => { return (
{value.toFixed(1)} {suffix ?? '%'}
) }) const Vector = React.forwardRef, React.ComponentPropsWithoutRef<'svg'> & { value: number }>( ({ className, children, value, ...props }, ref) => { const circumference = 2 * Math.PI * 45 // 45 is the radius of the circle const strokeDashoffset = circumference - (value / 100) * circumference return ( Circular Progress {value} ) }, ) export const CircularProgress = { Root, Label, Vector, }