From 308202a1dfd26018be7db74acbb3904c874e39b7 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Sun, 10 May 2026 16:58:17 -0400 Subject: [PATCH] =?UTF-8?q?refactor(web):=20extract=20CardActionCluster=20?= =?UTF-8?q?(#375=20item=20#8=20=E2=80=94=20narrowed=20scope)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MediaCard consolidation in the discovery doc would have needed ~14 props to cover the differentiating bits (wrapping element a vs button, art-shape, art-fallback strategy, click semantics, title align/size, subtitle count). That's a god-prop blob that's harder to reason about than three explicit cards. Narrowed to the actually-drifted bit: the action cluster (LikeButton + Plus + bottom-right menu slot, including the stopPropagation defensive wrappers). One small component covers AlbumCard / ArtistCard / CompactTrackCard so the focus-ring and button-styling drift can't recur. Each card keeps its own data-fetching, art container, and wrapping element since those have load-bearing differences. The consolidation addresses drift, not LOC for its own sake. Co-Authored-By: Claude Opus 4.7 (1M context) --- web/src/lib/components/AlbumCard.svelte | 38 ++++++------- web/src/lib/components/ArtistCard.svelte | 31 +++++------ .../lib/components/CardActionCluster.svelte | 55 +++++++++++++++++++ .../lib/components/CompactTrackCard.svelte | 33 ++++------- 4 files changed, 96 insertions(+), 61 deletions(-) create mode 100644 web/src/lib/components/CardActionCluster.svelte diff --git a/web/src/lib/components/AlbumCard.svelte b/web/src/lib/components/AlbumCard.svelte index ebb2df7e..5575ccb1 100644 --- a/web/src/lib/components/AlbumCard.svelte +++ b/web/src/lib/components/AlbumCard.svelte @@ -3,9 +3,9 @@ import { FALLBACK_COVER } from '$lib/media/covers'; import { api } from '$lib/api/client'; import { enqueueTracks, playQueue } from '$lib/player/store.svelte'; - import { Plus, Play } from 'lucide-svelte'; - import LikeButton from './LikeButton.svelte'; + import { Play } from 'lucide-svelte'; import AlbumMenu from './AlbumMenu.svelte'; + import CardActionCluster from './CardActionCluster.svelte'; let { album }: { album: AlbumRef } = $props(); @@ -58,24 +58,20 @@
{album.year}
{/if} -
- - -
-
- -
+ + {#snippet menu()} + + {/snippet} + diff --git a/web/src/lib/components/ArtistCard.svelte b/web/src/lib/components/ArtistCard.svelte index 8a2a4ff5..f1e1003a 100644 --- a/web/src/lib/components/ArtistCard.svelte +++ b/web/src/lib/components/ArtistCard.svelte @@ -2,9 +2,9 @@ import type { ArtistRef, TrackRef } from '$lib/api/types'; import { api } from '$lib/api/client'; import { playQueue, enqueueTracks } from '$lib/player/store.svelte'; - import { Disc3, Play, Plus } from 'lucide-svelte'; - import LikeButton from './LikeButton.svelte'; + import { Disc3, Play } from 'lucide-svelte'; import ArtistMenu from './ArtistMenu.svelte'; + import CardActionCluster from './CardActionCluster.svelte'; import { listArtistTracks } from '$lib/api/artists'; let { artist }: { artist: ArtistRef } = $props(); @@ -71,21 +71,16 @@
{artist.name}
-
- - -
- -
- -
+ + {#snippet menu()} + + {/snippet} + diff --git a/web/src/lib/components/CardActionCluster.svelte b/web/src/lib/components/CardActionCluster.svelte new file mode 100644 index 00000000..c92644b2 --- /dev/null +++ b/web/src/lib/components/CardActionCluster.svelte @@ -0,0 +1,55 @@ + + + + +
e.stopPropagation()}> + + +
+ + +
e.stopPropagation()}> + {@render menu()} +
diff --git a/web/src/lib/components/CompactTrackCard.svelte b/web/src/lib/components/CompactTrackCard.svelte index a1326945..ed526455 100644 --- a/web/src/lib/components/CompactTrackCard.svelte +++ b/web/src/lib/components/CompactTrackCard.svelte @@ -2,9 +2,8 @@ import type { TrackRef } from '$lib/api/types'; import { playQueue, enqueueTrack } from '$lib/player/store.svelte'; import { FALLBACK_COVER, coverUrl } from '$lib/media/covers'; - import { Plus } from 'lucide-svelte'; - import LikeButton from './LikeButton.svelte'; import TrackMenu from './TrackMenu.svelte'; + import CardActionCluster from './CardActionCluster.svelte'; let { track, @@ -52,24 +51,14 @@
{track.title}
{track.artist_name}
- - - -
e.stopPropagation()}> - - -
-
- -
+ + {#snippet menu()} + + {/snippet} +