From d72b6341a5d86d871b56628ea7912a86682b86b7 Mon Sep 17 00:00:00 2001 From: cialloo Date: Sun, 5 Oct 2025 07:58:00 +0800 Subject: [PATCH] Add loading animation for statistics display in App component --- src/App.css | 10 ++++++++ src/App.tsx | 69 ++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 73 insertions(+), 6 deletions(-) diff --git a/src/App.css b/src/App.css index b5dab76..d4ce642 100644 --- a/src/App.css +++ b/src/App.css @@ -524,3 +524,13 @@ .chat-feed::-webkit-scrollbar-thumb:hover { background: var(--accent-hover); } + +/* Loading Animation */ +@keyframes loading-shimmer { + 0% { + background-position: -200% 0; + } + 100% { + background-position: 200% 0; + } +} diff --git a/src/App.tsx b/src/App.tsx index 1dc7f02..9d19c99 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -33,6 +33,7 @@ function App() { totalPlayTime: 0, totalKills: 0 }) + const [loading, setLoading] = useState(true) const [recentChats, setRecentChats] = useState([]) const [topPlayers, setTopPlayers] = useState([]) @@ -77,8 +78,12 @@ function App() { totalPlayTime: playTime.totalPlayTime || 0, totalKills: kills.totalKillCount || 0 }) + setLoading(false) + }) + .catch(error => { + console.error('Error fetching stats:', error) + setLoading(false) }) - .catch(error => console.error('Error fetching stats:', error)) }, []) // Fetch recent chat messages (limit to top 5) @@ -188,22 +193,74 @@ function App() {
👥
-
{stats.totalPlayers.toLocaleString()}
+
+ {loading ? ( +
+ ) : ( + stats.totalPlayers.toLocaleString() + )} +
{t('stats.totalPlayers')}
-
-
{stats.totalConnects.toLocaleString()}
+
🔗
+
+ {loading ? ( +
+ ) : ( + stats.totalConnects.toLocaleString() + )} +
{t('stats.totalConnects')}
⏱️
-
{formatPlayTime(stats.totalPlayTime)}
+
+ {loading ? ( +
+ ) : ( + formatPlayTime(stats.totalPlayTime) + )} +
{t('stats.totalPlayTime')}
🎯
-
{stats.totalKills.toLocaleString()}
+
+ {loading ? ( +
+ ) : ( + stats.totalKills.toLocaleString() + )} +
{t('stats.totalKills')}