Skip to content

Commit 99474c4

Browse files
authored
Chores (#150)
* Adjust wording for sync popup * Refactor scroll feature and add scrolling effect
1 parent 50b8d1e commit 99474c4

4 files changed

Lines changed: 81 additions & 35 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const btn = document.getElementById("scroll-top-btn");
2+
3+
if (btn) {
4+
const THRESHOLD = 300;
5+
6+
window.addEventListener(
7+
"scroll",
8+
() => {
9+
btn.classList.toggle("visible", window.scrollY > THRESHOLD);
10+
},
11+
{ passive: true },
12+
);
13+
14+
btn.addEventListener("click", () => {
15+
document.body.classList.add("crt-scrolling");
16+
17+
const duration = 500; // ms
18+
const startY = window.scrollY;
19+
const startTime = performance.now();
20+
21+
function step(currentTime) {
22+
const elapsed = currentTime - startTime;
23+
const progress = Math.min(elapsed / duration, 1);
24+
25+
// Easing out cubic
26+
const easeProgress = 1 - Math.pow(1 - progress, 3);
27+
28+
// Add slight vertical jitter while scrolling up for CRT effect
29+
const jitter = progress < 1 ? Math.random() * 8 - 4 : 0;
30+
31+
window.scrollTo(0, Math.max(0, startY * (1 - easeProgress) + jitter));
32+
33+
if (progress < 1) {
34+
requestAnimationFrame(step);
35+
} else {
36+
document.body.classList.remove("crt-scrolling");
37+
}
38+
}
39+
40+
requestAnimationFrame(step);
41+
});
42+
}

frontend/js/leaderboard/sync-changes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ document.addEventListener("DOMContentLoaded", () => {
4040
body.innerHTML = "";
4141

4242
if (changes.no_changes) {
43-
body.innerHTML = `<div class="changes-content-line"><span style="color:var(--text-muted);">No changes detected since last sync.</span></div>`;
43+
body.innerHTML = `<div class="changes-content-line"><span style="color:var(--text-muted);">No changes detected in the most recent sync.</span></div>`;
4444
btn.classList.remove("pulse");
4545
return;
4646
}

frontend/leaderboard.html

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ <h1 class="page-title">Leaderboard</h1>
164164
<div id="changes-modal-overlay" class="changes-modal-overlay">
165165
<div class="changes-card">
166166
<div class="changes-card-header">
167-
<span class="changes-card-title">[SYNC_CHANGES]</span>
167+
<span class="changes-card-title">[ACTIVITY_LOG]</span>
168168
<button id="close-changes-btn" class="changes-card-close">
169169
[DISMISS]
170170
</button>
@@ -398,23 +398,7 @@ <h1 class="page-title">Leaderboard</h1>
398398
<!-- Scroll to Top button -->
399399
<button id="scroll-top-btn" aria-label="Scroll to top"></button>
400400

401-
<script nonce="__NONCE__">
402-
(function () {
403-
var btn = document.getElementById("scroll-top-btn");
404-
var THRESHOLD = 300;
405-
window.addEventListener(
406-
"scroll",
407-
function () {
408-
btn.classList.toggle("visible", window.scrollY > THRESHOLD);
409-
},
410-
{ passive: true },
411-
);
412-
btn.addEventListener("click", function () {
413-
window.scrollTo({ top: 0, behavior: "smooth" });
414-
});
415-
})();
416-
</script>
417-
401+
<script src="js/leaderboard/mobile-scroll-top.js"></script>
418402
<script src="js/leaderboard/sync-changes.js"></script>
419403
<script src="js/footer.js"></script>
420404
<script src="js/matrix.js"></script>

frontend/styles/main.css

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ body::after {
7777
);
7878
}
7979

80+
body.crt-scrolling {
81+
animation: flicker 0.3s infinite;
82+
filter: blur(0.5px) contrast(1.1) brightness(1.2);
83+
}
84+
8085
/* ── Animations ── */
8186
@keyframes blink {
8287
0%,
@@ -1038,6 +1043,7 @@ body::after {
10381043
-webkit-touch-callout: none;
10391044
-webkit-tap-highlight-color: transparent;
10401045
}
1046+
10411047
.mobile-score span {
10421048
user-select: none;
10431049
-webkit-user-select: none;
@@ -2259,6 +2265,7 @@ body::-webkit-scrollbar-thumb {
22592265
.score-caret::after {
22602266
content: ">";
22612267
}
2268+
22622269
@media (hover: hover) and (pointer: fine) {
22632270
.tooltip-score:hover .score-caret {
22642271
color: var(--cyan);
@@ -2269,12 +2276,14 @@ body::-webkit-scrollbar-thumb {
22692276
opacity: 1;
22702277
visibility: visible;
22712278
}
2279+
22722280
@media (hover: hover) and (pointer: fine) {
22732281
.tooltip-score:hover .score-tooltip {
22742282
opacity: 1;
22752283
visibility: visible;
22762284
}
22772285
}
2286+
22782287
.tooltip-score.active .score-caret {
22792288
transform: rotate(90deg);
22802289
color: var(--cyan);
@@ -2553,10 +2562,11 @@ body::-webkit-scrollbar-thumb {
25532562

25542563
/* scroll to top button */
25552564
#scroll-top-btn {
2556-
display: none; /* hidden on desktop entirely */
2565+
display: none;
2566+
/* hidden on desktop entirely */
25572567
position: fixed;
2558-
bottom: 1.5rem;
2559-
right: 1.25rem;
2568+
bottom: 70px;
2569+
right: 16px;
25602570
z-index: 111999;
25612571

25622572
visibility: hidden;
@@ -2565,30 +2575,38 @@ body::-webkit-scrollbar-thumb {
25652575

25662576
background: transparent;
25672577
border: 1px solid var(--green);
2578+
border-radius: 4px;
25682579
color: var(--green);
25692580

2570-
font-family: "Fira Code", monospace;
2571-
font-size: 0.75rem;
2581+
width: 38px;
2582+
height: 38px;
2583+
2584+
font-family: inherit;
2585+
font-size: 18px;
25722586
line-height: 1;
25732587

2574-
padding: 0.45rem 0.6rem;
2588+
align-items: center;
2589+
justify-content: center;
25752590
cursor: pointer;
25762591

25772592
box-shadow:
2578-
0 0 8px rgba(0, 229, 255, 0.25),
2579-
inset 0 0 8px rgba(0, 229, 255, 0.05);
2593+
0 0 8px rgba(0, 255, 65, 0.25),
2594+
inset 0 0 8px rgba(0, 255, 65, 0.05);
25802595

2581-
text-shadow: 0 0 6px rgba(0, 229, 255, 0.5);
2596+
text-shadow: 0 0 6px rgba(0, 255, 65, 0.5);
25822597

25832598
transition:
25842599
opacity 0.25s ease,
25852600
visibility 0.25s ease,
2586-
box-shadow 0.2s ease;
2601+
box-shadow 0.2s ease,
2602+
background 0.2s ease,
2603+
color 0.2s ease,
2604+
transform 0.2s ease;
25872605
}
25882606

2589-
@media (max-width: 768px) {
2607+
@media (max-width: 940px) {
25902608
#scroll-top-btn {
2591-
display: block;
2609+
display: flex;
25922610
}
25932611

25942612
#scroll-top-btn.visible {
@@ -2599,10 +2617,11 @@ body::-webkit-scrollbar-thumb {
25992617

26002618
#scroll-top-btn:active {
26012619
box-shadow:
2602-
0 0 14px rgba(0, 229, 255, 0.55),
2603-
inset 0 0 10px rgba(0, 229, 255, 0.15);
2604-
2605-
color: #fff;
2620+
0 0 14px rgba(0, 255, 65, 0.55),
2621+
inset 0 0 10px rgba(0, 255, 65, 0.15);
2622+
background: var(--green-dim);
2623+
color: var(--bg);
2624+
transform: translateY(0);
26062625
}
26072626
}
26082627

@@ -2730,6 +2749,7 @@ body::-webkit-scrollbar-thumb {
27302749
opacity: 1;
27312750
text-shadow: 0 0 5px var(--green);
27322751
}
2752+
27332753
50% {
27342754
opacity: 0;
27352755
text-shadow: none;

0 commit comments

Comments
 (0)