From 62e4050390bcd50b0619394190abdac243d208e2 Mon Sep 17 00:00:00 2001 From: sheikhlimon Date: Mon, 20 Oct 2025 00:11:28 +0600 Subject: [PATCH] fix(leaderboard, navbar): position rank badges & fix dashboard hamburger overlay --- .../dashboard/LeaderBoard/leaderboard.css | 31 +++++++++++++++++++ .../dashboard/LeaderBoard/leaderboard.tsx | 25 +++++++-------- src/pages/dashboard/dashboard.css | 4 +-- 3 files changed, 45 insertions(+), 15 deletions(-) diff --git a/src/components/dashboard/LeaderBoard/leaderboard.css b/src/components/dashboard/LeaderBoard/leaderboard.css index 5ba9518e..a3aa46eb 100644 --- a/src/components/dashboard/LeaderBoard/leaderboard.css +++ b/src/components/dashboard/LeaderBoard/leaderboard.css @@ -485,6 +485,11 @@ transition: background-color 0.2s ease; } +/* Ensure each contributor row is a positioning context so absolute rank badges stay inside the row */ +.contributor-row { + position: relative; +} + .light .contributor-row.even { background: #fff; } @@ -513,6 +518,32 @@ padding: 0 8px; } +/* Make rank cell a stable container for the badge (desktop + mobile) */ +.contributor-cell.rank-cell { + position: relative; + width: 40px; + padding: 8px; +} + +/* Position the badge inside the cell */ +.rank-badge { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + z-index: 10; + display: inline-flex; + align-items: center; + justify-content: center; + min-width: 28px; + height: 28px; + padding: 0 6px; + border-radius: 999px; + font-weight: 700; + font-size: 0.85rem; + line-height: 1; +} + .avatar { width: 40px; height: 40px; diff --git a/src/components/dashboard/LeaderBoard/leaderboard.tsx b/src/components/dashboard/LeaderBoard/leaderboard.tsx index 39496ccf..9a38e268 100644 --- a/src/components/dashboard/LeaderBoard/leaderboard.tsx +++ b/src/components/dashboard/LeaderBoard/leaderboard.tsx @@ -1,14 +1,7 @@ // src/components/dashboard/LeaderBoard/leaderboard.tsx import React, { JSX, useState } from "react"; import { motion } from "framer-motion"; -import { - FaTrophy, - FaStar, - FaCode, - FaUsers, - FaGithub, - FaSearch, -} from "react-icons/fa"; +import { FaStar, FaCode, FaUsers, FaGithub, FaSearch } from "react-icons/fa"; import { ChevronRight, ChevronLeft } from "lucide-react"; import { useColorMode } from "@docusaurus/theme-common"; import { useCommunityStatsContext } from "@site/src/lib/statsProvider"; @@ -528,12 +521,18 @@ export default function LeaderBoard(): JSX.Element { transition={{ duration: 0.3, delay: index * 0.05 }} className={`contributor-row ${isDark ? (index % 2 === 0 ? "even" : "odd") : index % 2 === 0 ? "even" : "odd"}`} > + {/* + This avoids indexOf() issues and is O(1). + */}
-
- {filteredContributors.indexOf(contributor) + 1} -
+ {(() => { + const rankIndex = indexOfFirst + index; // zero-based global index + return ( +
+ {rankIndex + 1} +
+ ); + })()}