Added counter for steam game counts

This commit is contained in:
Andreas Dahm committed 2026-04-28 15:41:38 +02:00
1 parent 2b5f77f0b9
commit 9569bbcd70
6 files changed
+82 -12

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
import React, {useState, useEffect} from 'react';
import {useTranslation} from 'react-i18next';
const SteamGameCount = ({targetCount}) => {
const {t} = useTranslation();
const [count, setCount] = useState(0);
useEffect(() => {
let startTime;
const duration = 1000; // 1 second
const startCount = 0;
const animate = (timestamp) => {
if (!startTime) startTime = timestamp;
const progress = Math.min((timestamp - startTime) / duration, 1);
const currentCount = Math.floor(progress * (targetCount - startCount) + startCount);
setCount(currentCount);
if (progress < 1) {
requestAnimationFrame(animate);
}
};
requestAnimationFrame(animate);
}, [targetCount]);
return (
<div className="flex flex-col items-center justify-center p-6 bg-white dark:bg-slate-800 rounded-xl shadow-sm border border-slate-200 dark:border-slate-700">
<div className="text-4xl font-bold text-blue-600 dark:text-blue-400 mb-2">
{count}
</div>
<div className="text-sm font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wider">
{t('DASHBOARD.STEAM_GAMES')}
</div>
</div>
);
};
export default SteamGameCount;