The first public release of Fabled Minstrel #158

Merged
bvandeusen merged 256 commits from dev into main 2026-12-03 21:41:58 -05:00
11 changed files with 80 additions and 100 deletions
Showing only changes of commit dae46ea980 - Show all commits
+13 -8
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { FALLBACK_COVER } from '#lib/media/covers.js'; import { FALLBACK_COVER } from '#lib/media/covers.js';
import { Disc3 } from 'lucide-svelte'; import { Disc3, Music2 } from 'lucide-svelte';
// Shared cover-artwork renderer. The web counterpart of Android's // Shared cover-artwork renderer. The web counterpart of Android's
// CoverTile/ServerImage: one place that owns the loading placeholder and // CoverTile/ServerImage: one place that owns the loading placeholder and
@@ -19,9 +19,10 @@
// 'round' clips to a circle (artist avatars); 'square' leaves clipping // 'round' clips to a circle (artist avatars); 'square' leaves clipping
// to the parent so existing rounded-md / rounded corners still apply. // to the parent so existing rounded-md / rounded corners still apply.
shape?: 'square' | 'round'; shape?: 'square' | 'round';
// 'artist' degrades to a Disc3 icon; 'image' to the static placeholder // 'artist' degrades to a Disc3 icon, 'track' to a Music2 icon (a track
// cover. A null/empty src is treated the same as a failed load. // row's thumbnail), 'image' to the static placeholder cover. A
fallback?: 'image' | 'artist'; // null/empty src is treated the same as a failed load.
fallback?: 'image' | 'artist' | 'track';
class?: string; class?: string;
} = $props(); } = $props();
@@ -35,7 +36,8 @@
failed = false; failed = false;
}); });
const useIcon = $derived(fallback === 'artist' && (failed || !src)); const FallbackIcon = $derived(fallback === 'artist' ? Disc3 : fallback === 'track' ? Music2 : null);
const useIcon = $derived(FallbackIcon !== null && (failed || !src));
// On failure for the image fallback, swap to the static placeholder asset. // On failure for the image fallback, swap to the static placeholder asset.
// src doesn't change on the second error, so there's no reload loop. // src doesn't change on the second error, so there's no reload loop.
const imgSrc = $derived(failed ? FALLBACK_COVER : src); const imgSrc = $derived(failed ? FALLBACK_COVER : src);
@@ -46,15 +48,18 @@
? 'rounded-full' ? 'rounded-full'
: ''}" : ''}"
> >
{#if useIcon} {#if useIcon && FallbackIcon}
<div class="flex h-full w-full items-center justify-center"> <div class="flex h-full w-full items-center justify-center">
<Disc3 strokeWidth={1} class="h-4/5 w-4/5 text-text-muted" /> <FallbackIcon
strokeWidth={1}
class="{fallback === 'track' ? 'h-1/2 w-1/2' : 'h-4/5 w-4/5'} text-text-muted"
/>
</div> </div>
{:else if imgSrc} {:else if imgSrc}
<img <img
src={imgSrc} src={imgSrc}
{alt} {alt}
class="h-full w-full object-cover transition-opacity duration-200 {loaded class="h-full w-full object-cover transition-[opacity,transform] duration-200 {loaded
? 'opacity-100' ? 'opacity-100'
: 'opacity-0'} {klass}" : 'opacity-0'} {klass}"
loading="lazy" loading="lazy"
+26
View File
@@ -0,0 +1,26 @@
import { describe, expect, test } from 'vitest';
import { render, fireEvent } from '@testing-library/svelte';
import Cover from './Cover.svelte';
describe('Cover', () => {
test('a track row with no cover shows the track icon, not an image', () => {
const { container } = render(Cover, { props: { src: undefined, fallback: 'track' } });
expect(container.querySelector('img')).toBeNull();
expect(container.querySelector('svg')).not.toBeNull();
});
test('a track cover that fails to load gives way to the track icon', async () => {
const { container } = render(Cover, { props: { src: '/api/albums/a1/cover', fallback: 'track' } });
const img = container.querySelector('img');
expect(img).not.toBeNull();
await fireEvent.error(img!);
expect(container.querySelector('img')).toBeNull();
expect(container.querySelector('svg')).not.toBeNull();
});
test('an image cover that fails to load shows the placeholder cover', async () => {
const { container } = render(Cover, { props: { src: '/api/albums/a1/cover' } });
await fireEvent.error(container.querySelector('img')!);
expect(container.querySelector('img')!.getAttribute('src')).not.toBe('/api/albums/a1/cover');
});
});
+8 -16
View File
@@ -12,7 +12,8 @@
toggleQueueDrawer toggleQueueDrawer
} from '#lib/player/store.svelte.js'; } from '#lib/player/store.svelte.js';
import { formatDuration } from '#lib/media/duration.js'; import { formatDuration } from '#lib/media/duration.js';
import { FALLBACK_COVER, coverUrl } from '#lib/media/covers.js'; import { coverUrl } from '#lib/media/covers.js';
import Cover from './Cover.svelte';
import { dominantColorFromUrl, rgbToCssString } from '#lib/media/dominantColor.js'; import { dominantColorFromUrl, rgbToCssString } from '#lib/media/dominantColor.js';
import { useSmoothPosition } from '#lib/player/smoothPosition.svelte.js'; import { useSmoothPosition } from '#lib/player/smoothPosition.svelte.js';
import LikeButton from './LikeButton.svelte'; import LikeButton from './LikeButton.svelte';
@@ -32,9 +33,6 @@
const onSeekInput = (e: Event) => seekTo(inputNumber(e)); const onSeekInput = (e: Event) => seekTo(inputNumber(e));
const onVolumeInput = (e: Event) => setVolume(inputNumber(e)); const onVolumeInput = (e: Event) => setVolume(inputNumber(e));
function onCoverError(e: Event) {
(e.currentTarget as HTMLImageElement).src = FALLBACK_COVER;
}
// Dominant-color accent. Sample the current track's cover and // Dominant-color accent. Sample the current track's cover and
// pipe it into a CSS custom property; a 2px strip above the bar // pipe it into a CSS custom property; a 2px strip above the bar
@@ -105,12 +103,9 @@
class="flex min-w-0 items-center gap-2 focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-accent" class="flex min-w-0 items-center gap-2 focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-accent"
style="flex: 1 1 35%;" style="flex: 1 1 35%;"
> >
<img <div class="h-12 w-12 shrink-0 overflow-hidden rounded-md">
src={coverUrl(current.album_id)} <Cover src={coverUrl(current.album_id)} />
alt="" </div>
class="h-12 w-12 shrink-0 rounded-md object-cover"
onerror={onCoverError}
/>
<div class="min-w-0"> <div class="min-w-0">
<div class="truncate text-sm font-medium text-text-primary">{current.title}</div> <div class="truncate text-sm font-medium text-text-primary">{current.title}</div>
<div class="truncate text-xs text-text-secondary">{current.artist_name}</div> <div class="truncate text-xs text-text-secondary">{current.artist_name}</div>
@@ -267,12 +262,9 @@
aria-label="Open now playing" aria-label="Open now playing"
class="shrink-0 focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-accent" class="shrink-0 focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-accent"
> >
<img <div class="h-24 w-24 overflow-hidden rounded-md">
src={coverUrl(current.album_id)} <Cover src={coverUrl(current.album_id)} />
alt="" </div>
class="h-24 w-24 rounded-md object-cover"
onerror={onCoverError}
/>
</a> </a>
<!-- Sized to the 96px cover beside it: the title reads at body size, <!-- Sized to the 96px cover beside it: the title reads at body size,
as Android's mini player gives it title weight. --> as Android's mini player gives it title weight. -->
+3 -6
View File
@@ -9,6 +9,7 @@
import { systemPlaylistRefetch } from '#lib/playlists/systemRefetch.js'; import { systemPlaylistRefetch } from '#lib/playlists/systemRefetch.js';
import { refreshedLabel, songsLikeArtist, washTone } from '#lib/playlists/shelf.js'; import { refreshedLabel, songsLikeArtist, washTone } from '#lib/playlists/shelf.js';
import { coverUrl } from '#lib/media/covers.js'; import { coverUrl } from '#lib/media/covers.js';
import Cover from './Cover.svelte';
import { dominantColorFromUrl, rgbToCssString } from '#lib/media/dominantColor.js'; import { dominantColorFromUrl, rgbToCssString } from '#lib/media/dominantColor.js';
import { errCode } from '#lib/api/errors.js'; import { errCode } from '#lib/api/errors.js';
import { qk } from '#lib/api/queries.js'; import { qk } from '#lib/api/queries.js';
@@ -225,7 +226,7 @@
{#snippet leadArt(rounded: string)} {#snippet leadArt(rounded: string)}
{#if lead} {#if lead}
<img src={lead} alt="" class="h-full w-full object-cover {rounded}" /> <Cover src={lead} class={rounded} />
{:else} {:else}
<div class="flex h-full w-full items-center justify-center text-text-muted"> <div class="flex h-full w-full items-center justify-center text-text-muted">
<span class="text-xs">No tracks yet</span> <span class="text-xs">No tracks yet</span>
@@ -312,11 +313,7 @@
group-hover:shadow-lg group-hover:ring-1 group-hover:ring-accent/40" group-hover:shadow-lg group-hover:ring-1 group-hover:ring-accent/40"
> >
{#if playlist.cover_url} {#if playlist.cover_url}
<img <Cover src={playlist.cover_url} class="group-hover:scale-105" />
src={playlist.cover_url}
alt=""
class="h-full w-full object-cover transition-transform group-hover:scale-105"
/>
{:else} {:else}
<div class="flex h-full w-full items-center justify-center text-text-muted"> <div class="flex h-full w-full items-center justify-center text-text-muted">
<span class="text-xs">No tracks yet</span> <span class="text-xs">No tracks yet</span>
+5 -7
View File
@@ -2,7 +2,8 @@
import { GripVertical, X } from 'lucide-svelte'; import { GripVertical, X } from 'lucide-svelte';
import type { TrackRef } from '#lib/api/types.js'; import type { TrackRef } from '#lib/api/types.js';
import { playFromQueueIndex, removeFromQueue, moveQueueItem } from '#lib/player/store.svelte.js'; import { playFromQueueIndex, removeFromQueue, moveQueueItem } from '#lib/player/store.svelte.js';
import { coverUrl, FALLBACK_COVER } from '#lib/media/covers.js'; import { coverUrl } from '#lib/media/covers.js';
import Cover from './Cover.svelte';
import { reorderDrag } from './reorder-drag'; import { reorderDrag } from './reorder-drag';
import LikeButton from './LikeButton.svelte'; import LikeButton from './LikeButton.svelte';
@@ -58,12 +59,9 @@
shadow is what keeps the glyph readable over pale covers without one. shadow is what keeps the glyph readable over pale covers without one.
--> -->
<div class="relative h-10 w-10 shrink-0"> <div class="relative h-10 w-10 shrink-0">
<img <div class="h-10 w-10 overflow-hidden rounded">
src={coverUrl(track.album_id)} <Cover src={coverUrl(track.album_id)} />
alt="" </div>
onerror={(e) => ((e.currentTarget as HTMLImageElement).src = FALLBACK_COVER)}
class="h-10 w-10 rounded object-cover"
/>
<button <button
type="button" type="button"
aria-label="Reorder track (use arrow keys)" aria-label="Reorder track (use arrow keys)"
+3 -1
View File
@@ -107,7 +107,9 @@ describe('QueueTrackRow', () => {
// Sharing a parent is what "overlaid" means structurally. If someone moves // Sharing a parent is what "overlaid" means structurally. If someone moves
// the grip back into its own flex slot, this fails — which is the point: // the grip back into its own flex slot, this fails — which is the point:
// that slot costs horizontal space in every row. // that slot costs horizontal space in every row.
expect(handle.parentElement).toBe(art!.parentElement); // The art sits inside Cover's own frame, so the shared parent is the
// frame's parent.
expect(handle.parentElement).toBe(art!.parentElement!.parentElement!.parentElement);
}); });
it('the handle is visible at rest, not hover-revealed', () => { it('the handle is visible at rest, not hover-revealed', () => {
+4 -15
View File
@@ -1,7 +1,8 @@
<script lang="ts"> <script lang="ts">
import Cover from '#lib/components/Cover.svelte';
import { plural } from '#lib/utils/plural.js'; import { plural } from '#lib/utils/plural.js';
import { pageTitle } from '#lib/branding.js'; import { pageTitle } from '#lib/branding.js';
import { Copy, Download, FolderX, Music2, Trash2 } from 'lucide-svelte'; import { Copy, Download, FolderX, Trash2 } from 'lucide-svelte';
import Modal from '#lib/components/Modal.svelte'; import Modal from '#lib/components/Modal.svelte';
import { createMissingFilesQuery, forgetMissingTracks, MISSING_FILES_CSV_URL } from '#lib/api/admin.js'; import { createMissingFilesQuery, forgetMissingTracks, MISSING_FILES_CSV_URL } from '#lib/api/admin.js';
import { errMessage } from '#lib/api/errors.js'; import { errMessage } from '#lib/api/errors.js';
@@ -172,20 +173,8 @@
<ul class="divide-y divide-border"> <ul class="divide-y divide-border">
{#each group.tracks as t (t.track_id)} {#each group.tracks as t (t.track_id)}
<li class="flex items-center gap-3 px-4 py-2" data-testid="missing-track-row"> <li class="flex items-center gap-3 px-4 py-2" data-testid="missing-track-row">
<div <div class="h-10 w-10 shrink-0 overflow-hidden rounded" aria-hidden="true">
class="flex h-10 w-10 shrink-0 items-center justify-center rounded bg-surface-hover" <Cover src={t.album_id ? coverUrl(t.album_id) : undefined} fallback="track" />
aria-hidden="true"
>
{#if t.album_id}
<img
src={coverUrl(t.album_id)}
alt=""
class="h-full w-full rounded object-cover"
loading="lazy"
/>
{:else}
<Music2 size={18} strokeWidth={1} class="text-text-muted" />
{/if}
</div> </div>
<div class="min-w-0 flex-1"> <div class="min-w-0 flex-1">
@@ -1,7 +1,8 @@
<script lang="ts"> <script lang="ts">
import Cover from '#lib/components/Cover.svelte';
import { plural } from '#lib/utils/plural.js'; import { plural } from '#lib/utils/plural.js';
import { pageTitle } from '#lib/branding.js'; import { pageTitle } from '#lib/branding.js';
import { Music2, CheckCircle2, Trash2, Play, Copy, ChevronRight, FileX } from 'lucide-svelte'; import { CheckCircle2, Trash2, Play, Copy, ChevronRight, FileX } from 'lucide-svelte';
import { useQueryClient } from '@tanstack/svelte-query'; import { useQueryClient } from '@tanstack/svelte-query';
import RowActionsMenu, { type RowAction } from '#lib/components/RowActionsMenu.svelte'; import RowActionsMenu, { type RowAction } from '#lib/components/RowActionsMenu.svelte';
import TabStrip from '#lib/components/TabStrip.svelte'; import TabStrip from '#lib/components/TabStrip.svelte';
@@ -208,12 +209,8 @@
{@const a = actionsFor(r)} {@const a = actionsFor(r)}
{@const open = !!expanded[r.track_id]} {@const open = !!expanded[r.track_id]}
<li class="flex items-start gap-4 p-3" data-testid="report-row"> <li class="flex items-start gap-4 p-3" data-testid="report-row">
<div class="flex h-12 w-12 shrink-0 items-center justify-center rounded-md bg-surface-hover" aria-hidden="true"> <div class="h-12 w-12 shrink-0 overflow-hidden rounded-md" aria-hidden="true">
{#if r.album_id} <Cover src={r.album_id ? coverUrl(r.album_id) : undefined} fallback="track" />
<img src={coverUrl(r.album_id)} alt="" class="h-full w-full rounded-md object-cover" loading="lazy" />
{:else}
<Music2 size={20} strokeWidth={1} class="text-text-muted" />
{/if}
</div> </div>
<div class="min-w-0 flex-1 space-y-1"> <div class="min-w-0 flex-1 space-y-1">
<div class="truncate text-sm font-medium text-text-primary">{r.title}</div> <div class="truncate text-sm font-medium text-text-primary">{r.title}</div>
@@ -1,7 +1,8 @@
<script lang="ts"> <script lang="ts">
import Cover from '#lib/components/Cover.svelte';
import { plural } from '#lib/utils/plural.js'; import { plural } from '#lib/utils/plural.js';
import { pageTitle } from '#lib/branding.js'; import { pageTitle } from '#lib/branding.js';
import { FileCheck, Music2 } from 'lucide-svelte'; import { FileCheck } from 'lucide-svelte';
import { createSuspectSourcesQuery, removeSuspectFile, setSuspectVerdict } from '#lib/api/admin.js'; import { createSuspectSourcesQuery, removeSuspectFile, setSuspectVerdict } from '#lib/api/admin.js';
import { errMessage } from '#lib/api/errors.js'; import { errMessage } from '#lib/api/errors.js';
import { pushToast } from '#lib/stores/toast.svelte.js'; import { pushToast } from '#lib/stores/toast.svelte.js';
@@ -158,20 +159,8 @@
<ul class="divide-y divide-border"> <ul class="divide-y divide-border">
{#each group.tracks as t (t.track_id)} {#each group.tracks as t (t.track_id)}
<li class="flex items-center gap-3 px-4 py-2" data-testid="suspect-track-row"> <li class="flex items-center gap-3 px-4 py-2" data-testid="suspect-track-row">
<div <div class="h-10 w-10 shrink-0 overflow-hidden rounded" aria-hidden="true">
class="flex h-10 w-10 shrink-0 items-center justify-center rounded bg-surface-hover" <Cover src={t.album_id ? coverUrl(t.album_id) : undefined} fallback="track" />
aria-hidden="true"
>
{#if t.album_id}
<img
src={coverUrl(t.album_id)}
alt=""
class="h-full w-full rounded object-cover"
loading="lazy"
/>
{:else}
<Music2 size={18} strokeWidth={1} class="text-text-muted" />
{/if}
</div> </div>
<div class="min-w-0 flex-1 space-y-0.5"> <div class="min-w-0 flex-1 space-y-0.5">
+4 -12
View File
@@ -1,7 +1,8 @@
<script lang="ts"> <script lang="ts">
import Cover from '#lib/components/Cover.svelte';
import KindPill from '#lib/components/KindPill.svelte'; import KindPill from '#lib/components/KindPill.svelte';
import { pageTitle } from '#lib/branding.js'; import { pageTitle } from '#lib/branding.js';
import { Music2, RotateCcw } from 'lucide-svelte'; import { RotateCcw } from 'lucide-svelte';
import { useQueryClient } from '@tanstack/svelte-query'; import { useQueryClient } from '@tanstack/svelte-query';
import { createMyQuarantineQuery, unflagTrack } from '#lib/api/quarantine.js'; import { createMyQuarantineQuery, unflagTrack } from '#lib/api/quarantine.js';
import { qk } from '#lib/api/queries.js'; import { qk } from '#lib/api/queries.js';
@@ -50,17 +51,8 @@
{#each rows as row (row.track_id)} {#each rows as row (row.track_id)}
<li class="flex items-start gap-3 rounded-md border border-border bg-surface p-3"> <li class="flex items-start gap-3 rounded-md border border-border bg-surface p-3">
<!-- Album art / fallback --> <!-- Album art / fallback -->
<div class="flex h-14 w-14 shrink-0 items-center justify-center rounded-md bg-surface-hover"> <div class="h-14 w-14 shrink-0 overflow-hidden rounded-md" aria-hidden="true">
{#if row.album_cover_art_path} <Cover src={row.album_cover_art_path ? coverUrl(row.album_id) : undefined} fallback="track" />
<img
src={coverUrl(row.album_id)}
alt=""
class="h-full w-full rounded-md object-cover"
loading="lazy"
/>
{:else}
<Music2 size={24} strokeWidth={1} class="text-text-muted" />
{/if}
</div> </div>
<!-- Body --> <!-- Body -->
<div class="flex flex-1 flex-col gap-1"> <div class="flex flex-1 flex-col gap-1">
+3 -10
View File
@@ -13,7 +13,8 @@
toggleQueueDrawer toggleQueueDrawer
} from '#lib/player/store.svelte.js'; } from '#lib/player/store.svelte.js';
import { formatDuration } from '#lib/media/duration.js'; import { formatDuration } from '#lib/media/duration.js';
import { FALLBACK_COVER, coverUrl } from '#lib/media/covers.js'; import { coverUrl } from '#lib/media/covers.js';
import Cover from '#lib/components/Cover.svelte';
import { dominantColorFromUrl, rgbToCssString } from '#lib/media/dominantColor.js'; import { dominantColorFromUrl, rgbToCssString } from '#lib/media/dominantColor.js';
import { useSmoothPosition } from '#lib/player/smoothPosition.svelte.js'; import { useSmoothPosition } from '#lib/player/smoothPosition.svelte.js';
import LikeButton from '#lib/components/LikeButton.svelte'; import LikeButton from '#lib/components/LikeButton.svelte';
@@ -50,9 +51,6 @@
const onSeekInput = (e: Event) => seekTo(inputNumber(e)); const onSeekInput = (e: Event) => seekTo(inputNumber(e));
const onVolumeInput = (e: Event) => setVolume(inputNumber(e)); const onVolumeInput = (e: Event) => setVolume(inputNumber(e));
function onCoverError(e: Event) {
(e.currentTarget as HTMLImageElement).src = FALLBACK_COVER;
}
function goBack() { function goBack() {
// Most users land here from the PlayerBar — history.back() returns // Most users land here from the PlayerBar — history.back() returns
// them to whatever surface they were on. If there's nothing to go // them to whatever surface they were on. If there's nothing to go
@@ -128,12 +126,7 @@
data-testid="now-playing-column" data-testid="now-playing-column"
> >
<div class="aspect-square w-full overflow-hidden rounded-lg bg-surface-hover shadow-lg"> <div class="aspect-square w-full overflow-hidden rounded-lg bg-surface-hover shadow-lg">
<img <Cover src={coverUrl(current.album_id)} />
src={coverUrl(current.album_id)}
alt=""
class="h-full w-full object-cover"
onerror={onCoverError}
/>
</div> </div>
<div class="w-full text-center"> <div class="w-full text-center">