import { useEffect } from 'react'; import type { ReactElement } from 'react'; import { motion, useSpring, useTransform } from 'motion/react'; import { cn } from '#utils'; import { Card } from '../Card/Card.tsx'; type StatisticCardProps = { [key: `data-${string}`]: unknown; className?: string; icon?: ReactElement; label: string; value: number; }; export const StatisticCard = ({ className, icon, label, value, ...props }: StatisticCardProps) => { const spring = useSpring(0, { bounce: 0 }); const rounded = useTransform(spring, (latest: number) => Math.floor(latest)); useEffect(() => { spring.set(value); }, [spring, value]); return ( {icon &&
{icon}
}
{rounded}

{label}

); };