From db2993c50b6bebe097eabf577e7f1eb687288a8b Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Fri, 12 Dec 2025 08:09:12 +0100 Subject: [PATCH] Refactor avatar display logic in LeaderboardSection: Simplify avatar rendering by consolidating conditional checks and enhancing fallback display for users without avatars, improving visual consistency and user experience. --- components/LeaderboardSection.tsx | 50 ++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/components/LeaderboardSection.tsx b/components/LeaderboardSection.tsx index f12dcb0..5f0ca8e 100644 --- a/components/LeaderboardSection.tsx +++ b/components/LeaderboardSection.tsx @@ -105,21 +105,28 @@ export default function LeaderboardSection({ {/* Player */}
- {entry.avatar ? ( -
+
+ {entry.avatar ? ( {entry.username} { + e.currentTarget.style.display = "none"; + e.currentTarget.nextElementSibling?.classList.remove( + "hidden" + ); + }} /> + ) : null} +
+ {entry.username.charAt(0).toUpperCase()}
- ) : ( -
- - {entry.username.charAt(0).toUpperCase()} - -
- )} +
setSelectedEntry(entry)} @@ -206,21 +213,28 @@ export default function LeaderboardSection({ {/* Avatar and Class */}
- {selectedEntry.avatar ? ( -
+
+ {selectedEntry.avatar ? ( {selectedEntry.username} { + e.currentTarget.style.display = "none"; + e.currentTarget.nextElementSibling?.classList.remove( + "hidden" + ); + }} /> + ) : null} +
+ {selectedEntry.username.charAt(0).toUpperCase()}
- ) : ( -
- - {selectedEntry.username.charAt(0).toUpperCase()} - -
- )} +
Rank #{selectedEntry.rank}