Skip to content

Commit 759829a

Browse files
authored
feat(result page): open daily leaderboard when clicking the daily leaderboard rank (@theiereman) (monkeytypegame#6133)
### Description Clicking on the rank (after getting a better rank in the daily leaderboard) will automatically open the leaderboard modal on the corresponding language screen ![gifgit](https://github.com/user-attachments/assets/92c974c5-acd1-4f2a-a7e7-bb61e30b692b) Honestly, I mostly added this for me because I like to go to the daily leaderboard after I did a good run and it was annoying me to have to open it + change the language to french + change to daily.
1 parent e6c800b commit 759829a

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

frontend/src/html/pages/test.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,14 @@
269269

270270
<div class="group dailyLeaderboard hidden">
271271
<div class="top">daily leaderboard</div>
272-
<div class="bottom">-</div>
272+
<div
273+
id="dailyLeaderboardRank"
274+
aria-label="Show daily leaderboard"
275+
data-balloon-pos="up"
276+
class="bottom"
277+
>
278+
-
279+
</div>
273280
</div>
274281

275282
<div class="group source hidden">

frontend/src/styles/test.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,6 @@
831831

832832
&.dailyLeaderboard {
833833
max-width: 13rem;
834-
overflow: hidden;
835834
white-space: nowrap;
836835
}
837836

frontend/src/ts/elements/leaderboards.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
LeaderboardRank,
2222
} from "@monkeytype/contracts/schemas/leaderboards";
2323
import { Mode } from "@monkeytype/contracts/schemas/shared";
24+
import * as TestStats from "../test/test-stats";
2425

2526
const wrapperId = "leaderboardsWrapper";
2627

@@ -973,4 +974,15 @@ $("header nav").on("click", ".textButton", (e) => {
973974
}
974975
});
975976

977+
$(".pageTest").on("click", "#dailyLeaderboardRank", () => {
978+
currentTimeRange = "daily";
979+
updateYesterdayButton();
980+
languageSelector?.enable();
981+
982+
currentLanguage = TestStats.lastResult.language;
983+
languageSelector?.setSelected(currentLanguage);
984+
void update();
985+
show();
986+
});
987+
976988
Skeleton.save(wrapperId);

0 commit comments

Comments
 (0)