feat(ui): make track artist and album clickable
This commit is contained in:
1 parent
e0b95b7264
commit
86c237ab02
4 files changed
+108
-5
No files matched your search
@@ -27,6 +27,8 @@
|
||||
hideFavorite?: boolean;
|
||||
compact?: boolean; // Compact mode: smaller height, artist as column
|
||||
onPlay?: () => void;
|
||||
onArtistClick?: () => void;
|
||||
onAlbumClick?: () => void;
|
||||
onDownload?: () => void;
|
||||
onRemoveDownload?: () => void;
|
||||
menuActions?: TrackMenuActions;
|
||||
@@ -59,6 +61,8 @@
|
||||
hideFavorite = false,
|
||||
compact = false,
|
||||
onPlay,
|
||||
onArtistClick,
|
||||
onAlbumClick,
|
||||
onDownload,
|
||||
onRemoveDownload,
|
||||
menuActions
|
||||
@@ -70,6 +74,8 @@
|
||||
// Use override if provided, otherwise use store
|
||||
const isFavorite = $derived(isFavoriteOverride ?? favoriteFromStore);
|
||||
const playNowAction = $derived(menuActions?.onPlayNow ?? onPlay);
|
||||
const artistClickAction = $derived(onArtistClick ?? menuActions?.onGoToArtist);
|
||||
const albumClickAction = $derived(onAlbumClick ?? menuActions?.onGoToAlbum);
|
||||
|
||||
// Subscribe to favorites store (only if trackId is provided)
|
||||
onMount(() => {
|
||||
@@ -89,6 +95,16 @@
|
||||
await toggleTrackFavorite(trackId);
|
||||
}
|
||||
}
|
||||
|
||||
function handleArtistClick(e: MouseEvent) {
|
||||
e.stopPropagation();
|
||||
artistClickAction?.();
|
||||
}
|
||||
|
||||
function handleAlbumClick(e: MouseEvent) {
|
||||
e.stopPropagation();
|
||||
albumClickAction?.();
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
@@ -122,18 +138,36 @@
|
||||
<div class="track-info">
|
||||
<div class="track-title" class:active={isPlaying}>{title}</div>
|
||||
{#if artist && !compact}
|
||||
<div class="track-artist">{artist}</div>
|
||||
{#if artistClickAction}
|
||||
<button class="track-artist track-link" type="button" onclick={handleArtistClick}>
|
||||
{artist}
|
||||
</button>
|
||||
{:else}
|
||||
<div class="track-artist">{artist}</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Artist Column (compact mode) -->
|
||||
{#if artist && compact}
|
||||
<div class="track-artist-column">{artist}</div>
|
||||
{#if artistClickAction}
|
||||
<button class="track-artist-column track-link" type="button" onclick={handleArtistClick}>
|
||||
{artist}
|
||||
</button>
|
||||
{:else}
|
||||
<div class="track-artist-column">{artist}</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<!-- Album Column -->
|
||||
{#if album}
|
||||
<div class="track-album">{album}</div>
|
||||
{#if albumClickAction}
|
||||
<button class="track-album track-link" type="button" onclick={handleAlbumClick}>
|
||||
{album}
|
||||
</button>
|
||||
{:else}
|
||||
<div class="track-album">{album}</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<!-- Duration -->
|
||||
@@ -320,6 +354,20 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.track-link {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.track-link:hover {
|
||||
color: var(--text-primary);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
|
||||
.track-duration {
|
||||
font-size: 14px;
|
||||
color: var(--text-muted);
|
||||
|
||||
@@ -507,7 +507,20 @@
|
||||
</div>
|
||||
<div class="track-info">
|
||||
<div class="track-title">{track.title}</div>
|
||||
<div class="track-album">{track.album?.title || ''}</div>
|
||||
{#if track.album?.id && onTrackGoToAlbum}
|
||||
<button
|
||||
class="track-album track-link"
|
||||
type="button"
|
||||
onclick={(event) => {
|
||||
event.stopPropagation();
|
||||
onTrackGoToAlbum?.(track.album!.id);
|
||||
}}
|
||||
>
|
||||
{track.album?.title || ''}
|
||||
</button>
|
||||
{:else}
|
||||
<div class="track-album">{track.album?.title || ''}</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="track-duration">{formatDuration(track.duration)}</div>
|
||||
<div class="track-actions">
|
||||
@@ -1186,6 +1199,20 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.track-link {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.track-link:hover {
|
||||
color: var(--text-primary);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
|
||||
.track-duration {
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
|
||||
@@ -594,6 +594,7 @@
|
||||
quality={getTrackQuality(track)}
|
||||
hideDownload={true}
|
||||
compact={true}
|
||||
onArtistClick={track.artistId && onArtistClick ? () => onArtistClick(track.artistId!) : undefined}
|
||||
onPlay={() => onTrackPlay?.(track)}
|
||||
menuActions={{
|
||||
onPlayNow: () => onTrackPlay?.(track)
|
||||
|
||||
@@ -385,7 +385,20 @@
|
||||
{/if}
|
||||
<div class="track-info">
|
||||
<div class="track-title">{track.title}</div>
|
||||
<div class="track-artist">{track.performer?.name || 'Unknown Artist'}</div>
|
||||
{#if track.performer?.id && onTrackGoToArtist}
|
||||
<button
|
||||
class="track-artist track-link"
|
||||
type="button"
|
||||
onclick={(event) => {
|
||||
event.stopPropagation();
|
||||
onTrackGoToArtist?.(track.performer!.id!);
|
||||
}}
|
||||
>
|
||||
{track.performer?.name || 'Unknown Artist'}
|
||||
</button>
|
||||
{:else}
|
||||
<div class="track-artist">{track.performer?.name || 'Unknown Artist'}</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="track-quality">{getQualityLabel(track)}</div>
|
||||
<div class="track-duration">{formatDuration(track.duration)}</div>
|
||||
@@ -694,6 +707,20 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.track-link {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.track-link:hover {
|
||||
color: var(--text-primary);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
|
||||
.track-quality {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
|
||||
Reference in new issue
Block a user