refactor(web): migrate 4 open-coded cover URL sites to coverUrl() helper (C1 small-win)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import type { TrackRef } from '$lib/api/types';
|
||||
import { playQueue, enqueueTrack } from '$lib/player/store.svelte';
|
||||
import { FALLBACK_COVER } from '$lib/media/covers';
|
||||
import { FALLBACK_COVER, coverUrl } from '$lib/media/covers';
|
||||
import { Plus } from 'lucide-svelte';
|
||||
import LikeButton from './LikeButton.svelte';
|
||||
import TrackMenu from './TrackMenu.svelte';
|
||||
@@ -16,7 +16,7 @@
|
||||
index: number;
|
||||
} = $props();
|
||||
|
||||
const coverUrl = $derived(`/api/albums/${track.album_id}/cover`);
|
||||
const cover = $derived(coverUrl(track.album_id));
|
||||
|
||||
function onImgError(e: Event) {
|
||||
(e.currentTarget as HTMLImageElement).src = FALLBACK_COVER;
|
||||
@@ -42,7 +42,7 @@
|
||||
>
|
||||
<div class="aspect-square w-full overflow-hidden rounded-md bg-surface-hover">
|
||||
<img
|
||||
src={coverUrl}
|
||||
src={cover}
|
||||
alt=""
|
||||
class="h-full w-full object-cover transition-transform group-hover:scale-[1.03]"
|
||||
loading="lazy"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
toggleQueueDrawer
|
||||
} from '$lib/player/store.svelte';
|
||||
import { formatDuration } from '$lib/media/duration';
|
||||
import { FALLBACK_COVER } from '$lib/media/covers';
|
||||
import { FALLBACK_COVER, coverUrl } from '$lib/media/covers';
|
||||
import LikeButton from './LikeButton.svelte';
|
||||
import TrackMenu from './TrackMenu.svelte';
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
class="shrink-0 focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent"
|
||||
>
|
||||
<img
|
||||
src={`/api/albums/${current.album_id}/cover`}
|
||||
src={coverUrl(current.album_id)}
|
||||
alt=""
|
||||
class="h-24 w-24 rounded-md object-cover"
|
||||
onerror={onCoverError}
|
||||
|
||||
Reference in New Issue
Block a user