feat(result page): open daily leaderboard when clicking the daily leaderboard rank (@theiereman) (#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.
This commit is contained in:
theiereman 2025-01-06 11:57:16 +01:00 committed by GitHub
parent e6c800b128
commit 759829a6fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 2 deletions

View file

@ -269,7 +269,14 @@
<div class="group dailyLeaderboard hidden">
<div class="top">daily leaderboard</div>
<div class="bottom">-</div>
<div
id="dailyLeaderboardRank"
aria-label="Show daily leaderboard"
data-balloon-pos="up"
class="bottom"
>
-
</div>
</div>
<div class="group source hidden">

View file

@ -831,7 +831,6 @@
&.dailyLeaderboard {
max-width: 13rem;
overflow: hidden;
white-space: nowrap;
}

View file

@ -21,6 +21,7 @@ import {
LeaderboardRank,
} from "@monkeytype/contracts/schemas/leaderboards";
import { Mode } from "@monkeytype/contracts/schemas/shared";
import * as TestStats from "../test/test-stats";
const wrapperId = "leaderboardsWrapper";
@ -973,4 +974,15 @@ $("header nav").on("click", ".textButton", (e) => {
}
});
$(".pageTest").on("click", "#dailyLeaderboardRank", () => {
currentTimeRange = "daily";
updateYesterdayButton();
languageSelector?.enable();
currentLanguage = TestStats.lastResult.language;
languageSelector?.setSelected(currentLanguage);
void update();
show();
});
Skeleton.save(wrapperId);