From df8bdb7ac076a79fd28bf342f6ac4dd6628faca3 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Fri, 30 Jan 2026 10:17:06 -0600 Subject: [PATCH] Add ticker animation for artist names and sorting to album sections in Favorites browse view - Artist names in sidepanel now animate with ticker effect on hover when text overflows - Each album section (Discography, EPs & Singles, Live Albums) now has a sort dropdown - Sort options: Default, Newest, Oldest, A-Z, Z-A - Use sorted arrays for rendering instead of raw grouped arrays --- src/lib/components/views/FavoritesView.svelte | 252 +++++++++++++++++- 1 file changed, 242 insertions(+), 10 deletions(-) diff --git a/src/lib/components/views/FavoritesView.svelte b/src/lib/components/views/FavoritesView.svelte index 1942cd900..c42f9b919 100644 --- a/src/lib/components/views/FavoritesView.svelte +++ b/src/lib/components/views/FavoritesView.svelte @@ -290,6 +290,78 @@ groupedArtistAlbumsByCategory.liveAlbums.length ); + // Sorting for album sections in browse view + type AlbumSortMode = 'default' | 'newest' | 'oldest' | 'title-asc' | 'title-desc'; + let discographySortMode = $state('default'); + let epsSinglesSortMode = $state('default'); + let liveAlbumsSortMode = $state('default'); + let showDiscographySortMenu = $state(false); + let showEpsSinglesSortMenu = $state(false); + let showLiveAlbumsSortMenu = $state(false); + + function sortQobuzAlbums(albums: QobuzAlbum[], mode: AlbumSortMode): QobuzAlbum[] { + if (mode === 'default') return albums; + return [...albums].sort((a, b) => { + switch (mode) { + case 'newest': { + const dateA = a.release_date_original || '0000'; + const dateB = b.release_date_original || '0000'; + return dateB.localeCompare(dateA); + } + case 'oldest': { + const dateA = a.release_date_original || '9999'; + const dateB = b.release_date_original || '9999'; + return dateA.localeCompare(dateB); + } + case 'title-asc': + return a.title.localeCompare(b.title); + case 'title-desc': + return b.title.localeCompare(a.title); + default: + return 0; + } + }); + } + + const sortedDiscography = $derived(sortQobuzAlbums(groupedArtistAlbumsByCategory.discography, discographySortMode)); + const sortedEpsSingles = $derived(sortQobuzAlbums(groupedArtistAlbumsByCategory.epsSingles, epsSinglesSortMode)); + const sortedLiveAlbums = $derived(sortQobuzAlbums(groupedArtistAlbumsByCategory.liveAlbums, liveAlbumsSortMode)); + + function getSortLabel(mode: AlbumSortMode): string { + switch (mode) { + case 'default': return 'Default'; + case 'newest': return 'Newest'; + case 'oldest': return 'Oldest'; + case 'title-asc': return 'A-Z'; + case 'title-desc': return 'Z-A'; + } + } + + // Ticker animation for long artist names in sidepanel + let hoveredArtistId = $state(null); + let artistNameOverflows = $state>(new Map()); + const tickerSpeed = 40; // px per second + + function measureArtistNameOverflow(artistId: number, element: HTMLElement | null) { + if (!element) return; + const textSpan = element.querySelector('.artist-name-text') as HTMLElement | null; + if (!textSpan) return; + const overflow = textSpan.scrollWidth - element.clientWidth; + if (overflow > 0) { + artistNameOverflows.set(artistId, overflow); + } else { + artistNameOverflows.delete(artistId); + } + } + + function getArtistNameTickerStyle(artistId: number): string { + if (hoveredArtistId !== artistId) return ''; + const overflow = artistNameOverflows.get(artistId); + if (!overflow || overflow <= 0) return ''; + const duration = (overflow + 16) / tickerSpeed; + return `--ticker-offset: -${overflow + 16}px; --ticker-duration: ${duration}s;`; + } + let showTracksContextMenu = $state(false); function resolveCustomIconSrc(path: string | null): string | null { if (!path) return null; @@ -1652,10 +1724,18 @@ {#each groupedArtistsSidepanel as group (group.id)}
{group.key}
{#each group.artists as artist (artist.id)} + {@const hasOverflow = artistNameOverflows.has(artist.id)} + {@const isHovered = hoveredArtistId === artist.id} + {#if showDiscographySortMenu} + + {/if} +
- {#each groupedArtistAlbumsByCategory.discography as album (album.id)} + {#each sortedDiscography as album (album.id)} - {#if groupedArtistAlbumsByCategory.epsSingles.length > 0} + {#if sortedEpsSingles.length > 0}
EPs & Singles - {groupedArtistAlbumsByCategory.epsSingles.length} + {sortedEpsSingles.length} +
+ + {#if showEpsSinglesSortMenu} + + {/if} +
- {#each groupedArtistAlbumsByCategory.epsSingles as album (album.id)} + {#each sortedEpsSingles as album (album.id)} - {#if groupedArtistAlbumsByCategory.liveAlbums.length > 0} + {#if sortedLiveAlbums.length > 0}
Live Albums - {groupedArtistAlbumsByCategory.liveAlbums.length} + {sortedLiveAlbums.length} +
+ + {#if showLiveAlbumsSortMenu} + + {/if} +
- {#each groupedArtistAlbumsByCategory.liveAlbums as album (album.id)} + {#each sortedLiveAlbums as album (album.id)}