feat(web/m7-377): ArtistCard top-right cluster + bottom-right kebab
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
<script lang="ts">
|
||||
import type { ArtistRef, TrackRef } from '$lib/api/types';
|
||||
import { api } from '$lib/api/client';
|
||||
import { playQueue } from '$lib/player/store.svelte';
|
||||
import { Disc3, Play } from 'lucide-svelte';
|
||||
import { playQueue, enqueueTracks } from '$lib/player/store.svelte';
|
||||
import { Disc3, Play, Plus } from 'lucide-svelte';
|
||||
import LikeButton from './LikeButton.svelte';
|
||||
import ArtistMenu from './ArtistMenu.svelte';
|
||||
import { listArtistTracks } from '$lib/api/artists';
|
||||
|
||||
let { artist }: { artist: ArtistRef } = $props();
|
||||
|
||||
let queueing = $state(false);
|
||||
|
||||
function shuffle<T>(items: T[]): T[] {
|
||||
const arr = items.slice();
|
||||
for (let i = arr.length - 1; i > 0; i--) {
|
||||
@@ -22,6 +27,19 @@
|
||||
if (tracks.length === 0) return;
|
||||
playQueue(shuffle(tracks), 0);
|
||||
}
|
||||
|
||||
async function onAddToQueue(e: MouseEvent) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if (queueing) return;
|
||||
queueing = true;
|
||||
try {
|
||||
const tracks = await listArtistTracks(artist.id);
|
||||
if (tracks.length > 0) enqueueTracks(tracks);
|
||||
} finally {
|
||||
queueing = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="card relative">
|
||||
@@ -53,6 +71,22 @@
|
||||
</div>
|
||||
<div class="mt-2 truncate text-center text-sm font-medium text-text-primary">{artist.name}</div>
|
||||
</a>
|
||||
<div class="absolute right-2 top-2 z-10 flex gap-1">
|
||||
<LikeButton entityType="artist" entityId={artist.id} />
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`Add ${artist.name} to queue`}
|
||||
onclick={onAddToQueue}
|
||||
disabled={queueing}
|
||||
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 disabled:opacity-50"
|
||||
>
|
||||
<Plus size={16} strokeWidth={1} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="absolute right-2 bottom-2 z-10">
|
||||
<ArtistMenu artistId={artist.id} artistName={artist.name} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user