feat: draw generated covers where a book has none

This commit is contained in:
2026-08-17 10:35:01 -04:00
parent 904d8fc76f
commit d16a90f08f
3 changed files with 27 additions and 3 deletions
@@ -10,6 +10,7 @@
import { Textarea } from '$lib/components/ui/textarea/index.js';
import { Badge } from '$lib/components/ui/badge/index.js';
import BookImage from '$lib/components/view/book-image.svelte';
import GeneratedCover from '$lib/components/view/generated-cover.svelte';
import { mergeBooks } from '$lib/api/book.remote';
import type { Book } from '$lib/schema';
@@ -132,6 +133,10 @@
<span class="{size} shrink-0 overflow-hidden rounded-sm border bg-muted">
{#if book.cover_image}
<BookImage src="/api/{book.cover_image}" class="h-full w-full object-cover" />
{:else}
<!-- Drawn rather than left blank, so the rail tells two coverless books
apart the same way the shelves do. -->
<GeneratedCover {book} />
{/if}
</span>
{/snippet}
@@ -1,7 +1,14 @@
<script lang="ts">
import type { Book } from '$lib/schema';
let { book, class: className = '' }: { book: Book; class?: string } = $props();
// Typed by what is drawn rather than by `Book`: the duplicates review holds
// candidates that carry a title and author names without a whole record, and a
// `Book` satisfies this shape anyway.
let {
book,
class: className = ''
}: {
book: { title: string; authors?: { name: string }[] | null };
class?: string;
} = $props();
/**
* Bookcloth tones rather than a point on the hue wheel.