- lucide-svelte is replaced by its successor @lucide/svelte. The component names are the same, so only the import path changes (44 files). - jsdom 31, @testing-library/jest-dom 8, @types/node 26. - The lockfile is refreshed within every range: svelte 5.60, vite 8.4, vitest 5.1, @sveltejs/kit 3.5, adapter-static 4.0.1. sharp is no longer in the tree. TypeScript stays on 6: svelte-check 4.7.9, the web lane's type check, accepts typescript ^5 || ^6 only. svelte-query 6 follows in its own commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
78 lines
2.4 KiB
Svelte
78 lines
2.4 KiB
Svelte
<script lang="ts">
|
|
import { ChevronLeft } from '@lucide/svelte';
|
|
import { plural } from '#lib/utils/plural.js';
|
|
import AlbumCard from './AlbumCard.svelte';
|
|
import EmptyState from './EmptyState.svelte';
|
|
import ListContinuation from './ListContinuation.svelte';
|
|
import type { AlbumRef, PagedQuery } from '#lib/api/types.js';
|
|
|
|
// One browse axis's albums (a genre, a year): a back link to the axis, the
|
|
// count, and the paged grid. A failed first page offers Try again; a failed
|
|
// later page keeps the grid and offers it at the end.
|
|
|
|
let {
|
|
query,
|
|
backHref,
|
|
backLabel,
|
|
title,
|
|
failText,
|
|
emptyTitle,
|
|
emptyHint,
|
|
endLabel
|
|
}: {
|
|
query: PagedQuery<AlbumRef> | null;
|
|
backHref: string;
|
|
backLabel: string;
|
|
title: string;
|
|
failText: string;
|
|
emptyTitle: string;
|
|
emptyHint: string;
|
|
endLabel: string;
|
|
} = $props();
|
|
|
|
const albums = $derived(query?.data?.pages.flatMap((p) => p.items) ?? []);
|
|
const total = $derived(query?.data?.pages[0]?.total ?? 0);
|
|
const failed = $derived(!!query?.isError && albums.length === 0);
|
|
</script>
|
|
|
|
<div class="space-y-4">
|
|
<header class="space-y-2">
|
|
<a href={backHref} class="inline-flex items-center gap-1 text-sm text-accent-fg hover:underline">
|
|
<ChevronLeft size={14} aria-hidden="true" />
|
|
{backLabel}
|
|
</a>
|
|
<div>
|
|
<h1 class="font-display text-2xl font-medium text-text-primary">{title}</h1>
|
|
{#if query && !query.isPending && !failed}
|
|
<p class="text-sm text-text-secondary">{plural(total, 'album', 'albums')}</p>
|
|
{/if}
|
|
</div>
|
|
</header>
|
|
|
|
{#if failed}
|
|
<p class="text-sm text-action-destructive">
|
|
{failText}
|
|
<button type="button" class="underline hover:no-underline" onclick={() => query?.refetch()}
|
|
>Try again</button
|
|
>
|
|
</p>
|
|
{:else if !query || query.isPending}
|
|
<p class="text-text-secondary">Loading…</p>
|
|
{:else if albums.length === 0}
|
|
<EmptyState title={emptyTitle} hint={emptyHint} />
|
|
{:else}
|
|
<div class="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6">
|
|
{#each albums as album (album.id)}
|
|
<AlbumCard {album} />
|
|
{/each}
|
|
</div>
|
|
<ListContinuation
|
|
hasMore={query.hasNextPage}
|
|
loading={query.isFetchingNextPage}
|
|
failed={query.isFetchNextPageError}
|
|
onMore={() => query?.fetchNextPage()}
|
|
{endLabel}
|
|
/>
|
|
{/if}
|
|
</div>
|