import {useEffect, useState} from 'react'; import {Link} from 'react-router-dom'; import {useTranslation} from 'react-i18next'; import {ArrowRight, Gamepad2} from 'lucide-react'; import {Card} from '@/components/ui/card'; import useReducedMotion from '../hooks/useReducedMotion.js'; const DURATION_MS = 1000; const COUNT_CLASS = 'block text-5xl font-bold tracking-tight tabular-nums'; const SteamGameCount = ({targetCount}) => { const {t} = useTranslation(); const reduce = useReducedMotion(); const [count, setCount] = useState(0); useEffect(() => { if (reduce) { setCount(targetCount); return undefined; } let frame; let startTime; const animate = (timestamp) => { startTime ??= timestamp; const progress = Math.min((timestamp - startTime) / DURATION_MS, 1); setCount(Math.floor(progress * targetCount)); if (progress < 1) { frame = requestAnimationFrame(animate); } }; frame = requestAnimationFrame(animate); return () => cancelAnimationFrame(frame); }, [targetCount, reduce]); return (
{targetCount > 0 ? {count} : {count}}
{t('DASHBOARD.GAMES')}
{t('DASHBOARD.TO_LIBRARY')} ); }; export default SteamGameCount;