From 17890e42e568074b66f3d9f5cce3e2e8decf377e Mon Sep 17 00:00:00 2001 From: pleb Date: Mon, 3 Nov 2025 11:07:31 -0800 Subject: [PATCH] finally got the playlist score bar gradient to clip at the score --- AGENTS.md | 4 +- .../tools/map-pack-discovery/+page.svelte | 85 +++++++++---------- 2 files changed, 43 insertions(+), 46 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 55d81d7..22c10c7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -15,5 +15,5 @@ ## Shell command guidance -- Whitelisted commands: `grep` -- DO NOT USE: `cd` (prefer `pwd`) +- Dont' use `cd`, prefer `pwd` +- Dont' use `rg`, prefer `grep -r` diff --git a/src/routes/tools/map-pack-discovery/+page.svelte b/src/routes/tools/map-pack-discovery/+page.svelte index 4c67422..2a66588 100644 --- a/src/routes/tools/map-pack-discovery/+page.svelte +++ b/src/routes/tools/map-pack-discovery/+page.svelte @@ -62,11 +62,15 @@ let playlistState: Record = {}; function togglePlaylist(id: number) { const currentlyExpanded = Boolean(expanded[id]); - expanded = { ...expanded, [id]: !currentlyExpanded }; + const nextExpanded: Record = {}; + if (!currentlyExpanded) { + nextExpanded[id] = true; + } + expanded = nextExpanded; if (!currentlyExpanded) { const state = playlistState[id]; - const offset = state ? state.offset : 0; - loadPlaylistMaps(id, offset); + const currentOffset = state && typeof state.offset === 'number' ? state.offset : 0; + loadPlaylistMaps(id, currentOffset); } } @@ -222,16 +226,9 @@ function scorePercent(avgScore: number | undefined | null): number | null { {playlist.stats?.totalMaps ?? 0} maps {#if scorePercent(playlist.stats?.avgScore) !== null} -
50 ? 'true' : 'false'} - > -
-
-
+ {@const pct = scorePercent(playlist.stats?.avgScore) ?? 0} +
+
{/if}
@@ -255,14 +252,15 @@ function scorePercent(avgScore: number | undefined | null): number | null { {#if expanded[playlist.playlistId]} + {@const state = playlistState[playlist.playlistId]}
- {#if playlistState[playlist.playlistId]?.loading} + {#if state?.loading}
Loading songs…
- {:else if playlistState[playlist.playlistId]?.error} -
{playlistState[playlist.playlistId]?.error}
- {:else if playlistState[playlist.playlistId]?.maps?.length} + {:else if state?.error} +
{state.error}
+ {:else if state?.maps?.length}
- {#each playlistState[playlist.playlistId].maps as card (card.id)} + {#each state.maps as card (card.id)} {/each}
- {#if playlistState[playlist.playlistId]?.total} + {#if state.total && state.total > SONGS_PER_PAGE}
- {#if playlistState[playlist.playlistId].total === 0} + {#if state.total === 0} No songs {:else} - Showing {playlistState[playlist.playlistId].offset + 1} + Showing {(state.offset ?? 0) + 1} - {Math.min( - playlistState[playlist.playlistId].offset + playlistState[playlist.playlistId].maps.length, - playlistState[playlist.playlistId].total ?? 0 + (state.offset ?? 0) + state.maps.length, + state.total ?? 0 )} - of {playlistState[playlist.playlistId].total} + of {state.total} {/if}