diff --git a/frontend/src/styles/inputs.scss b/frontend/src/styles/inputs.scss index d730671ae..ac9f8b781 100644 --- a/frontend/src/styles/inputs.scss +++ b/frontend/src/styles/inputs.scss @@ -108,6 +108,13 @@ select:-webkit-autofill:focus { color: var(--text-color); outline: none; } +.select2-container--default.select2-container--disabled + .select2-selection--single { + background: var(--sub-alt-color) !important; + opacity: 0.33; + cursor: default; + pointer-events: none; +} .select2-selection { background: var(--sub-alt-color); @@ -156,6 +163,11 @@ select:-webkit-autofill:focus { border-radius: var(--roundness); } +.select2-container--default.select2-container--disabled + .select2-selection--single { + background: #5051517a; +} + .select2-selection:focus { height: fit-content; height: -moz-fit-content; diff --git a/frontend/src/styles/leaderboards.scss b/frontend/src/styles/leaderboards.scss index 23b20d433..914b257f3 100644 --- a/frontend/src/styles/leaderboards.scss +++ b/frontend/src/styles/leaderboards.scss @@ -20,15 +20,18 @@ min-width: 100%; display: grid; align-items: center; - grid-template-columns: max-content auto 20rem; + grid-template-columns: auto 1fr 20rem; grid-template-areas: - "title yesterday buttons" - "subtitle subtitle buttons"; + "title title buttons" + "subtitle yesterday buttons"; .buttons { grid-area: buttons; - .buttonGroup .button { - padding: 0.4rem 2.18rem; + .timeRange { + grid-template-columns: 1fr 1fr; + .select2 { + grid-column: span 2; + } } } } @@ -41,6 +44,9 @@ .showYesterdayButton { grid-area: "yesterday"; margin-left: 1rem; + .fas { + margin-right: 0.3rem; + } } .subTitle { diff --git a/frontend/src/styles/z_media-queries.scss b/frontend/src/styles/z_media-queries.scss index c58e464cd..52458916e 100644 --- a/frontend/src/styles/z_media-queries.scss +++ b/frontend/src/styles/z_media-queries.scss @@ -7,7 +7,7 @@ font-size: 1rem; } .leaderboardsTop { - grid-template-columns: max-content; + grid-template-columns: auto 1fr max-content; .buttonGroup { grid-auto-flow: row; gap: 0.5rem; @@ -217,6 +217,10 @@ "subtitle subtitle" "yesterday yesterday" "buttons buttons"; + grid-template-columns: 1fr; + .buttons { + margin-top: 0.5rem; + } .buttonGroup { grid-auto-flow: column; } @@ -360,6 +364,9 @@ } } } + #leaderboardsWrapper #leaderboards .leaderboardsTop .buttonGroup { + grid-auto-flow: row; + } #commandLine, #commandLineInput { width: 500px !important; diff --git a/frontend/src/ts/elements/leaderboards.ts b/frontend/src/ts/elements/leaderboards.ts index 2a67fe68f..948ccdf07 100644 --- a/frontend/src/ts/elements/leaderboards.ts +++ b/frontend/src/ts/elements/leaderboards.ts @@ -9,6 +9,7 @@ import differenceInSeconds from "date-fns/differenceInSeconds"; import { getHTMLById as getBadgeHTMLbyId } from "../controllers/badge-controller"; let currentTimeRange: "allTime" | "daily" = "allTime"; +let currentLanguage = "english"; type LbKey = 15 | 60; @@ -351,8 +352,10 @@ function updateTitle(): void { const el = $("#leaderboardsWrapper .mainTitle"); const timeRangeString = currentTimeRange === "daily" ? "Daily" : "All-Time"; + const capitalizedLanguage = + currentLanguage.charAt(0).toUpperCase() + currentLanguage.slice(1); - el.text(`${timeRangeString} English Leaderboards`); + el.text(`${timeRangeString} ${capitalizedLanguage} Leaderboards`); } function updateYesterdayButton(): void { @@ -377,7 +380,7 @@ async function update(): Promise { const leaderboardRequests = timeModes.map((mode2) => { return Ape.leaderboards.get({ - language: "english", + language: currentLanguage, mode: "time", mode2, isDaily: currentTimeRange === "daily", @@ -389,7 +392,7 @@ async function update(): Promise { leaderboardRequests.push( ...timeModes.map((mode2) => { return Ape.leaderboards.getRank({ - language: "english", + language: currentLanguage, mode: "time", mode2, isDaily: currentTimeRange === "daily", @@ -462,7 +465,7 @@ async function requestMore(lb: LbKey, prepend = false): Promise { } const response = await Ape.leaderboards.get({ - language: "english", + language: currentLanguage, mode: "time", mode2: lb.toString(), isDaily: currentTimeRange === "daily", @@ -492,7 +495,7 @@ async function requestNew(lb: LbKey, skip: number): Promise { showLoader(lb); const response = await Ape.leaderboards.get({ - language: "english", + language: currentLanguage, mode: "time", mode2: lb.toString(), isDaily: currentTimeRange === "daily", @@ -568,10 +571,45 @@ $("#leaderboardsWrapper").on("click", (e) => { } }); -// $("#leaderboardsWrapper .buttons .button").on("click",(e) => { -// currentLeaderboard = $(e.target).attr("board"); -// update(); -// }); +const languageSelector = $( + "#leaderboardsWrapper #leaderboards .leaderboardsTop .buttonGroup.timeRange .languageSelect" +).select2({ + placeholder: "select a language", + width: "100%", + data: [ + { + id: "english", + text: "english", + selected: true, + }, + { + id: "spanish", + text: "spanish", + }, + { + id: "german", + text: "german", + }, + { + id: "portuguese", + text: "portuguese", + }, + { + id: "indonesian", + text: "indonesian", + }, + { + id: "italian", + text: "italian", + }, + ], +}); + +languageSelector.on("select2:select", (e) => { + currentLanguage = e.params.data.id; + updateTitle(); + update(); +}); let leftScrollEnabled = true; @@ -692,6 +730,10 @@ $( "#leaderboardsWrapper #leaderboards .leaderboardsTop .buttonGroup.timeRange .allTime" ).on("click", () => { currentTimeRange = "allTime"; + currentLanguage = "english"; + languageSelector.prop("disabled", true); + languageSelector.val("english"); + languageSelector.trigger("change"); update(); }); @@ -700,6 +742,7 @@ $( ).on("click", () => { currentTimeRange = "daily"; showYesterdayButton.removeClass("active"); + languageSelector.prop("disabled", false); update(); }); diff --git a/frontend/static/html/popups.html b/frontend/static/html/popups.html index f49643e90..ca9609dda 100644 --- a/frontend/static/html/popups.html +++ b/frontend/static/html/popups.html @@ -684,6 +684,7 @@
all-time
daily
+