diff --git a/src/ui/code-blocks/ShelfCodeBlock.ts b/src/ui/code-blocks/ShelfCodeBlock.ts index 89ffaf7..09ae970 100644 --- a/src/ui/code-blocks/ShelfCodeBlock.ts +++ b/src/ui/code-blocks/ShelfCodeBlock.ts @@ -15,7 +15,7 @@ export function registerShelfCodeBlockProcessor( ); } -export const SHELF_VIEWS = ["table", "bookshelf"] as const; +export const SHELF_VIEWS = ["table", "bookshelf", "details"] as const; export type ShelfView = (typeof SHELF_VIEWS)[number]; export const ShelfSettingsSchema = z.object({ @@ -27,10 +27,13 @@ export const ShelfSettingsSchema = z.object({ titleProperty: z.string(), subtitleProperty: z.optional(z.string()), authorsProperty: z.string(), + descriptionProperty: z.optional(z.string()), seriesTitleProperty: z.optional(z.string()), seriesNumberProperty: z.optional(z.string()), }); +export type ShelfSettings = z.infer; + export class ShelfCodeBlockRenderer extends SvelteCodeBlockRenderer< typeof ShelfCodeBockView > { diff --git a/src/ui/code-blocks/ShelfCodeBlockView.svelte b/src/ui/code-blocks/ShelfCodeBlockView.svelte index fac2569..1615dae 100644 --- a/src/ui/code-blocks/ShelfCodeBlockView.svelte +++ b/src/ui/code-blocks/ShelfCodeBlockView.svelte @@ -1,50 +1,31 @@ @@ -148,139 +45,24 @@ class="shelf-code-block" class:table-view={view === "table"} class:bookshelf-view={view === "bookshelf"} + class:details-view={view === "details"} >
{#if settings.statusFilter === STATUS_READ} {/if}
{#if view === "bookshelf"} - - {#each books as book (book.id)} - {#if "books" in book} - - {#each book.books as bookData (bookData.id)} - - plugin.app.workspace - .getLeaf("tab") - .openFile(bookData.file)} - /> - {/each} - - {:else} - - plugin.app.workspace - .getLeaf("tab") - .openFile(book.file)} - /> - {/if} - {/each} - + {:else if view === "table"} - - - - - - - {#if settings.seriesTitleProperty} - - {/if} - {#if settings.seriesNumberProperty} - - {/if} - {#if settings.statusFilter === STATUS_IN_PROGRESS || settings.statusFilter === STATUS_READ} - - {/if} - {#if settings.statusFilter === STATUS_READ} - - - {/if} - - - - {#each metadataStore.metadata as book} - - - - - {#if settings.seriesTitleProperty} - - {/if} - {#if settings.seriesNumberProperty} - - {/if} - {#if settings.statusFilter === STATUS_IN_PROGRESS || settings.statusFilter === STATUS_READ} - - {/if} - {#if settings.statusFilter === STATUS_READ} - - - {/if} - - {/each} - -
CoverTitleAuthorsSeries#Start DateEnd DateRating
- {book.frontmatter[settings.titleProperty]} - - - {book.frontmatter[settings.titleProperty]} - - - {book.frontmatter[settings.authorsProperty].join( - ", ", - )} - - {book.frontmatter[settings.seriesTitleProperty]} - - {book.frontmatter[ - settings.seriesNumberProperty - ]} - - {book.frontmatter[ - settingsStore.settings.startDateProperty - ]} - - {book.frontmatter[ - settingsStore.settings.endDateProperty - ]} - - -
+ + {:else if view === "details"} + {/if} diff --git a/src/ui/components/BookshelfView.svelte b/src/ui/components/BookshelfView.svelte new file mode 100644 index 0000000..0acb3d0 --- /dev/null +++ b/src/ui/components/BookshelfView.svelte @@ -0,0 +1,164 @@ + + + + {#each books as book (book.id)} + {#if "books" in book} + + {#each book.books as bookData (bookData.id)} + + plugin.app.workspace + .getLeaf("tab") + .openFile(bookData.file)} + /> + {/each} + + {:else} + + plugin.app.workspace.getLeaf("tab").openFile(book.file)} + /> + {/if} + {/each} + diff --git a/src/ui/components/DetailsView.svelte b/src/ui/components/DetailsView.svelte new file mode 100644 index 0000000..12bb08e --- /dev/null +++ b/src/ui/components/DetailsView.svelte @@ -0,0 +1,199 @@ + + +
+ {#each metadataStore.metadata as book} + {@const coverPath = book.frontmatter[settings.coverProperty]} + {@const title = book.frontmatter[settings.titleProperty]} + {@const subtitle = settings.subtitleProperty + ? book.frontmatter[settings.subtitleProperty] + : undefined} + {@const authors = book.frontmatter[settings.authorsProperty]} + {@const description = settings.descriptionProperty + ? book.frontmatter[settings.descriptionProperty] + : undefined} + {@const seriesTitle = settings.seriesTitleProperty + ? book.frontmatter[settings.seriesTitleProperty] + : undefined} + {@const seriesNumber = settings.seriesNumberProperty + ? book.frontmatter[settings.seriesNumberProperty] + : undefined} + {@const startDate = + book.frontmatter[settingsStore.settings.startDateProperty]} + {@const endDate = + book.frontmatter[settingsStore.settings.endDateProperty]} + {@const rating = + book.frontmatter[settingsStore.settings.ratingProperty] ?? 0} + {@const spice = + book.frontmatter[settingsStore.settings.spiceProperty] ?? 0} + +
+ {title} +
+ +

+ {title} +

+
+ {#if subtitle} +

{subtitle}

+ {/if} +

By: {authors.join(", ")}

+ {#if seriesTitle} +

+ {seriesTitle} + {#if seriesNumber} + #{seriesNumber} + {/if} +

+ {/if} + {#if description} +
+

{@html description}

+
+ {/if} + +
+
+ {/each} +
+ + diff --git a/src/ui/components/RatingInput.svelte b/src/ui/components/RatingInput.svelte index 9da2bf7..b8946d8 100644 --- a/src/ui/components/RatingInput.svelte +++ b/src/ui/components/RatingInput.svelte @@ -7,6 +7,8 @@ name?: string; max?: number; half?: boolean; + iconSize?: number; + disabled?: boolean; inactive?: Snippet; active?: Snippet; partial?: Snippet; @@ -14,9 +16,10 @@ let { value = $bindable(), - name = "", max = 5, half = false, + iconSize = 64, + disabled, inactive, active, partial, @@ -36,7 +39,9 @@ let hovering = $state(false); let valueHover = $state(0); - let displayVal = $derived(hovering ? valueHover : (value ?? 0)); + let displayVal = $derived( + hovering && !disabled ? valueHover : (value ?? 0), + ); let items = $derived.by(() => { const full = Number.isInteger(displayVal); return Array.from({ length: max }, (_, i) => i + 1).map((index) => ({ @@ -80,7 +85,12 @@ -
+
@@ -132,14 +142,14 @@ :global(svg) { position: absolute; - width: 100%; - height: 100%; + width: var(--icon-size); + height: var(--icon-size); } .rating-item { position: relative; - width: var(--size-4-16); - height: var(--size-4-16); + width: var(--icon-size); + height: var(--icon-size); } } diff --git a/src/ui/components/TableView.svelte b/src/ui/components/TableView.svelte new file mode 100644 index 0000000..b2bc17b --- /dev/null +++ b/src/ui/components/TableView.svelte @@ -0,0 +1,113 @@ + + + + + + + + + {#if settings.seriesTitleProperty} + + {/if} + {#if settings.seriesNumberProperty} + + {/if} + {#if settings.statusFilter === STATUS_IN_PROGRESS || settings.statusFilter === STATUS_READ} + + {/if} + {#if settings.statusFilter === STATUS_READ} + + + {/if} + + + + {#each metadataStore.metadata as book} + {@const coverPath = book.frontmatter[settings.coverProperty]} + {@const title = book.frontmatter[settings.titleProperty]} + {@const authors = book.frontmatter[settings.authorsProperty]} + {@const seriesTitle = settings.seriesTitleProperty + ? book.frontmatter[settings.seriesTitleProperty] + : undefined} + {@const seriesNumber = settings.seriesNumberProperty + ? book.frontmatter[settings.seriesNumberProperty] + : undefined} + {@const startDate = + book.frontmatter[settingsStore.settings.startDateProperty]} + {@const endDate = + book.frontmatter[settingsStore.settings.endDateProperty]} + {@const rating = + book.frontmatter[settingsStore.settings.ratingProperty] ?? 0} + {@const spice = + book.frontmatter[settingsStore.settings.spiceProperty] ?? 0} + + + + + + {#if settings.seriesTitleProperty} + + {/if} + {#if settings.seriesNumberProperty} + + {/if} + {#if settings.statusFilter === STATUS_IN_PROGRESS || settings.statusFilter === STATUS_READ} + + {/if} + {#if settings.statusFilter === STATUS_READ} + + + {/if} + + {/each} + +
CoverTitleAuthorsSeries#Start DateEnd DateRating
+ {title} + + + {title} + + + {authors.join(", ")} + + {#if seriesTitle}{seriesTitle}{/if} + + {#if seriesNumber}{seriesNumber}{/if} + + {startDate} + + {endDate} + + +
+ +