|
11 | 11 | rel="stylesheet" |
12 | 12 | /> |
13 | 13 | <link rel="stylesheet" href="styles/main.css" /> |
| 14 | + <style> |
| 15 | +#scrollTopBtn { |
| 16 | + position: fixed; |
| 17 | + bottom: 20px; |
| 18 | + right: 20px; |
| 19 | + |
| 20 | + display: none; |
| 21 | + z-index: 999; |
| 22 | + |
| 23 | + padding: 0.7rem 1rem; |
| 24 | + |
| 25 | + font-family: "Fira Code", monospace; |
| 26 | + font-size: 0.8rem; |
| 27 | + font-weight: 600; |
| 28 | + |
| 29 | + color: var(--green); |
| 30 | + background: rgba(0, 0, 0, 0.85); |
| 31 | + |
| 32 | + border: 1px solid var(--green); |
| 33 | + border-radius: 6px; |
| 34 | + |
| 35 | + cursor: pointer; |
| 36 | + |
| 37 | + text-shadow: 0 0 5px rgba(0, 255, 100, 0.5); |
| 38 | + box-shadow: 0 0 10px rgba(0, 255, 100, 0.15); |
| 39 | + |
| 40 | + transition: all 0.25s ease; |
| 41 | +} |
| 42 | + |
| 43 | +#scrollTopBtn:hover { |
| 44 | + transform: translateY(-3px); |
| 45 | + background: rgba(0, 255, 100, 0.08); |
| 46 | + box-shadow: |
| 47 | + 0 0 12px rgba(0, 255, 100, 0.35), |
| 48 | + 0 0 20px rgba(0, 255, 100, 0.15); |
| 49 | +} |
| 50 | + |
| 51 | +#scrollTopBtn:active { |
| 52 | + transform: translateY(0); |
| 53 | +} |
| 54 | +</style> |
14 | 55 | <link rel="icon" type="image/png" href="assets/logo.png" /> |
15 | 56 | <script src="js/navbar.js"></script> |
16 | 57 | </head> |
@@ -81,7 +122,7 @@ <h1 class="page-title">Leaderboard</h1> |
81 | 122 | autocomplete="off" |
82 | 123 | spellcheck="false" |
83 | 124 | /> |
84 | | - |
| 125 | + |
85 | 126 | <span class="search-result-count" id="search-result-count"></span> |
86 | 127 | <kbd class="search-shortcut" id="search-shortcut">Ctrl+K</kbd> |
87 | 128 | <button |
@@ -145,6 +186,10 @@ <h1 class="page-title">Leaderboard</h1> |
145 | 186 | </div> |
146 | 187 | </main> |
147 | 188 |
|
| 189 | + <button id="scrollTopBtn" aria-label="Scroll to top"> |
| 190 | + [ ↑ TOP ] |
| 191 | + </button> |
| 192 | + |
148 | 193 | <script> |
149 | 194 | document.addEventListener("DOMContentLoaded", () => { |
150 | 195 | document.querySelectorAll(".tab").forEach((tab) => { |
@@ -220,6 +265,24 @@ <h1 class="page-title">Leaderboard</h1> |
220 | 265 | } |
221 | 266 | }); |
222 | 267 | clearBtn.style.display = "none"; |
| 268 | + |
| 269 | + const scrollTopBtn = document.getElementById("scrollTopBtn"); |
| 270 | + |
| 271 | +window.addEventListener("scroll", () => { |
| 272 | + if (window.scrollY > 300) { |
| 273 | + scrollTopBtn.style.display = "block"; |
| 274 | + } else { |
| 275 | + scrollTopBtn.style.display = "none"; |
| 276 | + } |
| 277 | +}); |
| 278 | + |
| 279 | +scrollTopBtn.addEventListener("click", () => { |
| 280 | + window.scrollTo({ |
| 281 | + top: 0, |
| 282 | + behavior: "smooth", |
| 283 | + }); |
| 284 | +}); |
| 285 | + |
223 | 286 | fetchLeaderboardData(); |
224 | 287 | }); |
225 | 288 |
|
|
0 commit comments