Skip to content

Commit f78cdfe

Browse files
adding loading bar to match previews
1 parent c3f2d8e commit f78cdfe

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

app.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ async function loadMatches() {
233233
liveContainer.innerHTML = '';
234234
finishedContainer.innerHTML = '';
235235

236+
const total = gameEntries.length;
237+
let loaded = 0;
238+
236239
for (const game of Object.values(games)) {
237240
const { lichessGameId, white, black, status } = game;
238241
if (!lichessGameId) continue;
@@ -268,7 +271,12 @@ async function loadMatches() {
268271
} else {
269272
finishedContainer.appendChild(card);
270273
}
274+
275+
loaded++;
276+
const percent = Math.round((loaded / total) * 100);
277+
document.getElementById('games-loading-bar').style.width = `${percent}%`;
271278
}
279+
document.getElementById('games-loading-bar-container').style.display = 'none';
272280
}
273281

274282
function hideIframeLoader(iframe) {

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,17 @@ <h3>Troll Reports</h3>
5252
</div>
5353

5454
<h2>Live Games</h2>
55+
<div id="games-loading-bar-container">
56+
<div id="games-loading-bar"></div>
57+
</div>
5558
<div class="scroll-container">
5659
<div id="live-matches" class="matches-row"></div>
5760
</div>
5861

5962
<h2>Finished Games</h2>
63+
<div id="games-loading-bar-container">
64+
<div id="games-loading-bar"></div>
65+
</div>
6066
<div class="scroll-container">
6167
<div id="finished-matches" class="matches-row"></div>
6268
</div>

style.css

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,19 @@ a:active {
261261
border-radius: 4px;
262262
}
263263

264-
264+
#games-loading-bar-container {
265+
height: 6px;
266+
width: 100%;
267+
background-color: #ddd;
268+
margin: 1rem 0;
269+
position: relative;
270+
border-radius: 3px;
271+
overflow: hidden;
272+
}
273+
274+
#games-loading-bar {
275+
height: 100%;
276+
width: 0%;
277+
background-color: #4CAF50;
278+
transition: width 0.2s ease;
279+
}

0 commit comments

Comments
 (0)