refactor(web): extract CardActionCluster (#375 item #8 — narrowed scope)

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) <noreply@anthropic.com>
This commit is contained in:
2026-05-10 16:58:17 -04:00
parent 9b4f907db6
commit 308202a1df
4 changed files with 96 additions and 61 deletions
+17 -21
View File
@@ -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 @@
<div class="text-xs text-text-secondary">{album.year}</div>
{/if}
</a>
<div class="absolute right-2 top-2 z-10 flex gap-1">
<LikeButton entityType="album" entityId={album.id} />
<button
type="button"
aria-label="Add to queue"
onclick={onAddClick}
class="rounded-full bg-surface px-2 py-1 text-sm text-text-secondary hover:text-text-primary focus-visible:ring-2 focus-visible:ring-accent"
>
<Plus size={16} strokeWidth={1} />
</button>
</div>
<div class="absolute right-2 bottom-2 z-10">
<AlbumMenu
albumId={album.id}
albumTitle={album.title}
artistId={album.artist_id}
artistName={album.artist_name}
/>
</div>
<CardActionCluster
likeEntityType="album"
likeEntityId={album.id}
onAdd={onAddClick}
addLabel="Add to queue"
>
{#snippet menu()}
<AlbumMenu
albumId={album.id}
albumTitle={album.title}
artistId={album.artist_id}
artistName={album.artist_name}
/>
{/snippet}
</CardActionCluster>
</div>