Just use page count for book width

This commit is contained in:
Evan Fiordeliso 2025-07-05 10:51:06 -04:00
parent b9f146f922
commit 94fe4d5f1c
2 changed files with 5 additions and 7 deletions

View File

@ -84,8 +84,6 @@
return 1; return 1;
} }
} }
const calculateWidth = (pageCount: number) =>
Math.max(10, Math.min(1000, 200 + pageCount * 10));
function getBookData(metadata: FileMetadata): BookData { function getBookData(metadata: FileMetadata): BookData {
return { return {
@ -94,9 +92,9 @@
? metadata.frontmatter[settings.subtitleProperty] ? metadata.frontmatter[settings.subtitleProperty]
: undefined, : undefined,
author: metadata.frontmatter[settings.authorsProperty].join(", "), author: metadata.frontmatter[settings.authorsProperty].join(", "),
width: calculateWidth( width: metadata.frontmatter[
metadata.frontmatter[settingsStore.settings.pageCountProperty], settingsStore.settings.pageCountProperty
), ],
color: randomColor(), color: randomColor(),
design: randomDesign(), design: randomDesign(),
orientation: randomOrientation(), orientation: randomOrientation(),

View File

@ -41,7 +41,7 @@
onClick, onClick,
}: BookProps = $props(); }: BookProps = $props();
function widthCheck(input: number | undefined) { function normalizeWidth(input: number | undefined) {
if (input) { if (input) {
if (input <= 150) { if (input <= 150) {
return BOOK_SIZE_MIN; return BOOK_SIZE_MIN;
@ -57,7 +57,7 @@
: Color.fromCSSColor(colorRaw), : Color.fromCSSColor(colorRaw),
); );
const verifiedWidth = $derived(widthCheck(width)); const verifiedWidth = $derived(normalizeWidth(width));
</script> </script>
{#if orientation} {#if orientation}