|
4 | 4 | detectAdBlockEnabled, |
5 | 5 | openGame, |
6 | 6 | } from "$lib/helpers.js"; |
7 | | - import { SessionState, State } from "$lib/state.js"; |
| 7 | + import { initializeTooling, SessionState, State } from "$lib/state.js"; |
8 | 8 | import type { Game } from "$lib/types/game.js"; |
9 | 9 | import { onMount } from "svelte"; |
10 | 10 | import GameCard from "./GameCard.svelte"; |
11 | 11 | import Ad from "./Ad.svelte"; |
12 | 12 | import { findAHosts } from "$lib/types/servers.js"; |
13 | 13 | import { browser } from "$app/environment"; |
| 14 | + import { loadGames } from "$lib/loadCards.js"; |
14 | 15 |
|
15 | | - const props: { games: Game[] } = $props(); |
16 | 16 | let searchIsOpen = $state(false); |
17 | | - const { games } = props; |
18 | | -
|
| 17 | + let games = $state<Game[]>([]); |
19 | 18 | let adsEnabled = $state(false); |
20 | 19 | let adSlots = $state<{ sidebar: string; grid: string } | null>(null); |
21 | 20 |
|
|
82 | 81 | }); |
83 | 82 | } |
84 | 83 | console.log( |
85 | | - `Sorted games by ${sortType}:`, |
86 | | - sorted.length |
87 | | - ) |
| 84 | + `[R][CardGrid][getSortedGames] Sorted games by ${sortType}, found ${sorted.length} games.`, |
| 85 | + ); |
88 | 86 | return sorted; |
89 | 87 | } |
90 | 88 |
|
|
179 | 177 | const searchRegex = /[a-z0-9]/i; |
180 | 178 | let adBlock = $state(false); |
181 | 179 | onMount(async () => { |
| 180 | + await initializeTooling(); |
| 181 | +
|
| 182 | + games = await loadGames(); |
| 183 | +
|
182 | 184 | document.addEventListener("keydown", (e) => { |
183 | 185 | if (!searchInput) return; |
184 | 186 | // Ignore keyboard shortcuts, special keys, non a-z0-9, or backspace, enter, delete, etc. |
|
226 | 228 | if (SessionState.ssr) return; |
227 | 229 |
|
228 | 230 | await detectAdBlockEnabled(); |
229 | | - console.log("AdBlock Enabled:", SessionState.adBlockEnabled); |
| 231 | + console.log("[R][CardGrid][Mount] AdBlock Enabled:", SessionState.adBlockEnabled); |
230 | 232 | adBlock = SessionState.adBlockEnabled; |
231 | 233 | adsEnabled = SessionState.adsEnabled; |
232 | 234 | if (adsEnabled) { |
|
395 | 397 | </button> |
396 | 398 | </div> |
397 | 399 | <div class="card-grid {State.homeView}"> |
| 400 | + {#if games.length === 0} |
| 401 | + {#each Array(12) as _, i} |
| 402 | + <div class="load-shimmer"> </div> |
| 403 | + {/each} |
| 404 | + {/if} |
398 | 405 | {#each getSortedGames() as game, i (game.gameID)} |
399 | 406 | <GameCard |
400 | 407 | {game} |
|
411 | 418 | {#if !adBlock && !adsEnabled} |
412 | 419 | {#if (i + 1) % 10 === 0} |
413 | 420 | <div class="inxxx agrid grid"> |
414 | | - <div style="text-align: center; font-size: 0.9rem; color: #555;width:100%;height:100%;display: flex;flex-direction: column;justify-content: center;align-items: center;"> |
415 | | - <p>Contact <a href="mailto:ccported@ccported.click">ccported@ccported.click</a> to advertise in this slot</p> |
| 421 | + <div |
| 422 | + style="text-align: center; font-size: 0.9rem; color: #555;width:100%;height:100%;display: flex;flex-direction: column;justify-content: center;align-items: center;" |
| 423 | + > |
| 424 | + <p> |
| 425 | + Contact <a |
| 426 | + href="mailto:ccported@ccported.click" |
| 427 | + >ccported@ccported.click</a |
| 428 | + > to advertise in this slot |
| 429 | + </p> |
416 | 430 | </div> |
417 | 431 | </div> |
418 | 432 | {/if} |
|
430 | 444 | </div> |
431 | 445 |
|
432 | 446 | <style> |
| 447 | + .load-shimmer { |
| 448 | + width: 90%; |
| 449 | + height: 280px; |
| 450 | + border-radius: 16px; |
| 451 | + border: 1px solid #e0e0e0; |
| 452 | + background: linear-gradient( |
| 453 | + 90deg, |
| 454 | + #f0f0f0 0%, |
| 455 | + #e0e0e0 50%, |
| 456 | + #f0f0f0 100% |
| 457 | + ); |
| 458 | + background-size: 200% 100%; |
| 459 | + animation: shimmer 1.5s infinite linear; |
| 460 | + margin-bottom: 20px; |
| 461 | + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); |
| 462 | + } |
| 463 | +
|
| 464 | + @keyframes shimmer { |
| 465 | + 0% { |
| 466 | + background-position: 200% 0; |
| 467 | + } |
| 468 | + 100% { |
| 469 | + background-position: -200% 0; |
| 470 | + } |
| 471 | + } |
433 | 472 | .container { |
434 | 473 | width: 100%; |
435 | 474 | box-sizing: border-box; |
|
0 commit comments