From 94fe4d5f1c959a0798f80bc9039ee2ecfaf7fb5c Mon Sep 17 00:00:00 2001 From: Evan Fiordeliso Date: Sat, 5 Jul 2025 10:51:06 -0400 Subject: [PATCH] Just use page count for book width --- src/ui/code-blocks/BookshelfCodeBlockView.svelte | 8 +++----- src/ui/components/bookshelf/Book.svelte | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/ui/code-blocks/BookshelfCodeBlockView.svelte b/src/ui/code-blocks/BookshelfCodeBlockView.svelte index cc2e81e..5e0fd9a 100644 --- a/src/ui/code-blocks/BookshelfCodeBlockView.svelte +++ b/src/ui/code-blocks/BookshelfCodeBlockView.svelte @@ -84,8 +84,6 @@ return 1; } } - const calculateWidth = (pageCount: number) => - Math.max(10, Math.min(1000, 200 + pageCount * 10)); function getBookData(metadata: FileMetadata): BookData { return { @@ -94,9 +92,9 @@ ? metadata.frontmatter[settings.subtitleProperty] : undefined, author: metadata.frontmatter[settings.authorsProperty].join(", "), - width: calculateWidth( - metadata.frontmatter[settingsStore.settings.pageCountProperty], - ), + width: metadata.frontmatter[ + settingsStore.settings.pageCountProperty + ], color: randomColor(), design: randomDesign(), orientation: randomOrientation(), diff --git a/src/ui/components/bookshelf/Book.svelte b/src/ui/components/bookshelf/Book.svelte index 71bbd9e..285f5cd 100644 --- a/src/ui/components/bookshelf/Book.svelte +++ b/src/ui/components/bookshelf/Book.svelte @@ -41,7 +41,7 @@ onClick, }: BookProps = $props(); - function widthCheck(input: number | undefined) { + function normalizeWidth(input: number | undefined) { if (input) { if (input <= 150) { return BOOK_SIZE_MIN; @@ -57,7 +57,7 @@ : Color.fromCSSColor(colorRaw), ); - const verifiedWidth = $derived(widthCheck(width)); + const verifiedWidth = $derived(normalizeWidth(width)); {#if orientation}