diff --git a/src/lib/components/views/LocalLibraryView.svelte b/src/lib/components/views/LocalLibraryView.svelte index a5b1ac746..7192575d8 100644 --- a/src/lib/components/views/LocalLibraryView.svelte +++ b/src/lib/components/views/LocalLibraryView.svelte @@ -391,6 +391,8 @@ let artistViewMode = $state<'grid' | 'list'>('grid'); let artistGroupingEnabled = $state(true); // Enable alpha grouping by default let showArtistGroupMenu = $state(false); + // Selected artist for the two-column layout + let selectedArtistName = $state(null); let artistImageFetchInProgress = false; // Guard against concurrent fetches let artistImageFetchAborted = false; // Flag to abort fetching let trackSearch = $state(''); @@ -531,6 +533,16 @@ return { filtered, grouped, alphaGroups }; }); + // Albums for the selected artist (used in artist view two-column layout) + let selectedArtistAlbums = $derived.by(() => { + if (!selectedArtistName) return []; + const normalizedSelected = normalizeArtistName(selectedArtistName); + return albums.filter(album => { + const normalizedArtist = normalizeArtistName(album.artist); + return normalizedArtist === normalizedSelected; + }); + }); + // Fast album search without function call overhead function matchesAlbumSearchFast(album: LocalAlbum, needle: string): boolean { const lowerNeedle = needle.toLowerCase(); @@ -1961,19 +1973,11 @@ return (exactMatch ?? results.items[0]).id; } - async function handleLocalArtistClick(name?: string) { - if (!name || !onQobuzArtistClick) return; + function handleLocalArtistClick(name?: string) { + if (!name) return; if (normalizeArtistName(name) === 'various artists') return; - try { - const artistId = await resolveQobuzArtistId(name); - if (artistId) { - onQobuzArtistClick(artistId); - } else { - console.warn('No Qobuz artist match for local artist:', name); - } - } catch (err) { - console.error('Failed to resolve Qobuz artist for local artist:', name, err); - } + // Select artist to show their albums in the right column + selectedArtistName = name; } /** @@ -2936,96 +2940,108 @@ {:else} {@const { grouped: groupedArtists, alphaGroups: artistAlphaGroups } = groupedArtistsMemo} {@const filteredArtists = filteredArtistsMemo} -
- - {#if filteredArtists.length === 0} -
- -

No artists match your search

-
- {:else} - -
- {#if artistViewMode === 'grid'} -
- + +
+ +
+
+ {filteredArtists.length} artists +
+ {#if filteredArtists.length === 0} +
+ +

No artists match your search

{:else} - -
- -
- {/if} - - {#if artistGroupingEnabled} -
- {#each alphaIndexLetters as letter} - +
+ {#each groupedArtists as group} + {#if group.key} +
+ {group.key} +
+ {/if} + {#each group.artists as artist} + {@const displayName = getArtistDisplayName(artist.name)} + {@const artistImage = artistImages.get(artist.name)} + + {/each} {/each}
{/if}
- {/if} + + +
+ {#if selectedArtistName} +
+

{getArtistDisplayName(selectedArtistName)}

+ {selectedArtistAlbums.length} albums +
+ {#if selectedArtistAlbums.length === 0} +
+ +

No albums found

+
+ {:else} +
+ {#each selectedArtistAlbums as album} + handleAlbumPlayFromGrid(album)} + onPlayNext={() => handleAlbumQueueNextFromGrid(album)} + onPlayLater={() => handleAlbumQueueLaterFromGrid(album)} + onclick={() => handleAlbumClick(album)} + sourceBadge={album.source === 'qobuz_download' ? 'qobuz_download' : 'user'} + /> + {/each} +
+ {/if} + {:else} +
+ +

Select an artist to view their albums

+
+ {/if} +
+
{/if} {:else if activeTab === 'tracks'} {#if tracks.length === 0} @@ -5392,4 +5408,221 @@ .footer-hint { margin-top: 0; } + + /* Artist View - Two Column Layout */ + .artist-alpha-index-horizontal { + display: flex; + flex-wrap: wrap; + gap: 4px; + padding: 8px 0 16px; + border-bottom: 1px solid var(--bg-tertiary); + margin-bottom: 16px; + } + + .alpha-letter-horizontal { + width: 28px; + height: 28px; + display: flex; + align-items: center; + justify-content: center; + font-size: 12px; + font-weight: 500; + color: var(--text-secondary); + background: var(--bg-secondary); + border: none; + border-radius: 4px; + cursor: pointer; + transition: all 150ms ease; + } + + .alpha-letter-horizontal:hover:not(.disabled) { + background: var(--accent-primary); + color: white; + } + + .alpha-letter-horizontal.disabled { + opacity: 0.3; + cursor: default; + pointer-events: none; + } + + .artist-two-column-layout { + display: flex; + gap: 24px; + height: calc(100vh - 320px); + min-height: 400px; + } + + .artist-column { + width: 220px; + flex-shrink: 0; + display: flex; + flex-direction: column; + background: var(--bg-secondary); + border-radius: 12px; + overflow: hidden; + } + + .artist-column-header { + padding: 12px 16px; + border-bottom: 1px solid var(--bg-tertiary); + } + + .artist-count { + font-size: 12px; + color: var(--text-muted); + } + + .artist-list-scroll { + flex: 1; + overflow-y: auto; + padding: 8px; + } + + .artist-group-header { + font-size: 11px; + font-weight: 600; + color: var(--text-muted); + padding: 12px 8px 4px; + text-transform: uppercase; + letter-spacing: 0.5px; + } + + .artist-card-compact { + display: flex; + align-items: center; + gap: 12px; + width: 100%; + padding: 8px; + background: transparent; + border: none; + border-radius: 8px; + cursor: pointer; + transition: background 150ms ease; + text-align: left; + } + + .artist-card-compact:hover { + background: var(--bg-tertiary); + } + + .artist-card-compact.selected { + background: var(--accent-primary); + } + + .artist-card-compact.selected .artist-name { + color: white; + } + + .artist-card-compact.selected .artist-meta { + color: rgba(255, 255, 255, 0.7); + } + + .artist-card-image { + width: 48px; + height: 48px; + flex-shrink: 0; + border-radius: 50%; + overflow: hidden; + } + + .artist-card-image img { + width: 100%; + height: 100%; + object-fit: cover; + } + + .artist-placeholder { + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-primary) 100%); + color: var(--text-muted); + } + + .artist-card-info { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + gap: 2px; + } + + .artist-card-info .artist-name { + font-size: 13px; + font-weight: 500; + color: var(--text-primary); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .artist-card-info .artist-meta { + font-size: 11px; + color: var(--text-muted); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + .artist-albums-column { + flex: 1; + display: flex; + flex-direction: column; + min-width: 0; + overflow: hidden; + } + + .artist-albums-header { + display: flex; + align-items: baseline; + gap: 12px; + padding-bottom: 16px; + border-bottom: 1px solid var(--bg-tertiary); + margin-bottom: 16px; + } + + .artist-albums-header h3 { + margin: 0; + font-size: 20px; + font-weight: 600; + color: var(--text-primary); + } + + .artist-albums-header .album-count { + font-size: 13px; + color: var(--text-muted); + } + + .artist-albums-grid { + flex: 1; + overflow-y: auto; + display: grid; + grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); + gap: 16px; + align-content: start; + padding-right: 8px; + } + + .empty-small { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 12px; + padding: 32px; + color: var(--text-muted); + text-align: center; + } + + .empty-small.centered { + flex: 1; + } + + .empty-small p { + margin: 0; + font-size: 13px; + }