Skip to content

Commit 62e4050

Browse files
committed
fix(leaderboard, navbar): position rank badges & fix dashboard hamburger overlay
1 parent 700cf93 commit 62e4050

File tree

3 files changed

+45
-15
lines changed

3 files changed

+45
-15
lines changed

src/components/dashboard/LeaderBoard/leaderboard.css

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,11 @@
485485
transition: background-color 0.2s ease;
486486
}
487487

488+
/* Ensure each contributor row is a positioning context so absolute rank badges stay inside the row */
489+
.contributor-row {
490+
position: relative;
491+
}
492+
488493
.light .contributor-row.even {
489494
background: #fff;
490495
}
@@ -513,6 +518,32 @@
513518
padding: 0 8px;
514519
}
515520

521+
/* Make rank cell a stable container for the badge (desktop + mobile) */
522+
.contributor-cell.rank-cell {
523+
position: relative;
524+
width: 40px;
525+
padding: 8px;
526+
}
527+
528+
/* Position the badge inside the cell */
529+
.rank-badge {
530+
position: absolute;
531+
top: 50%;
532+
left: 50%;
533+
transform: translate(-50%, -50%);
534+
z-index: 10;
535+
display: inline-flex;
536+
align-items: center;
537+
justify-content: center;
538+
min-width: 28px;
539+
height: 28px;
540+
padding: 0 6px;
541+
border-radius: 999px;
542+
font-weight: 700;
543+
font-size: 0.85rem;
544+
line-height: 1;
545+
}
546+
516547
.avatar {
517548
width: 40px;
518549
height: 40px;

src/components/dashboard/LeaderBoard/leaderboard.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
// src/components/dashboard/LeaderBoard/leaderboard.tsx
22
import React, { JSX, useState } from "react";
33
import { motion } from "framer-motion";
4-
import {
5-
FaTrophy,
6-
FaStar,
7-
FaCode,
8-
FaUsers,
9-
FaGithub,
10-
FaSearch,
11-
} from "react-icons/fa";
4+
import { FaStar, FaCode, FaUsers, FaGithub, FaSearch } from "react-icons/fa";
125
import { ChevronRight, ChevronLeft } from "lucide-react";
136
import { useColorMode } from "@docusaurus/theme-common";
147
import { useCommunityStatsContext } from "@site/src/lib/statsProvider";
@@ -528,12 +521,18 @@ export default function LeaderBoard(): JSX.Element {
528521
transition={{ duration: 0.3, delay: index * 0.05 }}
529522
className={`contributor-row ${isDark ? (index % 2 === 0 ? "even" : "odd") : index % 2 === 0 ? "even" : "odd"}`}
530523
>
524+
{/*
525+
This avoids indexOf() issues and is O(1).
526+
*/}
531527
<div className={`contributor-cell rank-cell`}>
532-
<div
533-
className={`rank-badge ${getRankClass(filteredContributors.indexOf(contributor))}`}
534-
>
535-
{filteredContributors.indexOf(contributor) + 1}
536-
</div>
528+
{(() => {
529+
const rankIndex = indexOfFirst + index; // zero-based global index
530+
return (
531+
<div className={`rank-badge ${getRankClass(rankIndex)}`}>
532+
{rankIndex + 1}
533+
</div>
534+
);
535+
})()}
537536
</div>
538537
<div className="contributor-cell avatar-cell">
539538
<img

src/pages/dashboard/dashboard.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
position: fixed;
1313
top: 70px;
1414
left: 20px;
15-
z-index: 1100;
15+
z-index: 100;
1616
background: var(--ifm-color-primary);
1717
color: white;
1818
border: none;
@@ -32,7 +32,7 @@
3232
}
3333

3434
.dashboard-menu-btn.open {
35-
background: #dc3545;
35+
display: none;
3636
}
3737

3838
/* Mobile Menu */

0 commit comments

Comments
 (0)