From 28201f5d8890f740df82bac4f00e4091d0ad3cb9 Mon Sep 17 00:00:00 2001 From: ZXY101 Date: Sat, 13 Jan 2024 17:53:21 +0200 Subject: [PATCH] Add misc settings + misc cleanup --- src/lib/components/Catalog.svelte | 56 +++++++++++++++++++---- src/lib/components/CatalogListItem.svelte | 25 ++++++++++ src/lib/components/VolumeItem.svelte | 3 +- src/lib/settings/index.ts | 3 +- src/lib/settings/misc.ts | 33 +++++++++++++ src/lib/settings/settings.ts | 1 - src/routes/[manga]/+page.svelte | 4 +- 7 files changed, 111 insertions(+), 14 deletions(-) create mode 100644 src/lib/components/CatalogListItem.svelte create mode 100644 src/lib/settings/misc.ts diff --git a/src/lib/components/Catalog.svelte b/src/lib/components/Catalog.svelte index a3519f3..05e09d4 100644 --- a/src/lib/components/Catalog.svelte +++ b/src/lib/components/Catalog.svelte @@ -1,17 +1,41 @@ {#if $catalog} @@ -19,8 +43,16 @@
- + +
{#if search && sortedCatalog.length === 0}
@@ -28,9 +60,17 @@
{:else}
- {#each sortedCatalog as { id } (id)} - - {/each} + {#if $miscSettings.galleryLayout === 'grid'} + {#each sortedCatalog as { id } (id)} + + {/each} + {:else} + + {#each sortedCatalog as { id } (id)} + + {/each} + + {/if}
{/if}
diff --git a/src/lib/components/CatalogListItem.svelte b/src/lib/components/CatalogListItem.svelte new file mode 100644 index 0000000..967d5c8 --- /dev/null +++ b/src/lib/components/CatalogListItem.svelte @@ -0,0 +1,25 @@ + + +{#if manga} +
+ + +
+

{manga.mokuroData.title}

+ img +
+
+
+
+{/if} diff --git a/src/lib/components/VolumeItem.svelte b/src/lib/components/VolumeItem.svelte index 02065a0..69d7b3d 100644 --- a/src/lib/components/VolumeItem.svelte +++ b/src/lib/components/VolumeItem.svelte @@ -1,5 +1,4 @@ - +
(stored ? JSON.parse(stored) : defaultSettings); + +miscSettings.subscribe((miscSettings) => { + if (browser) { + window.localStorage.setItem('miscSettings', JSON.stringify(miscSettings)); + } +}); + +export function updateMiscSetting(key: MiscSettingsKey, value: any) { + miscSettings.update((miscSettings) => { + return { + ...miscSettings, + [key]: value + }; + }); +} \ No newline at end of file diff --git a/src/lib/settings/settings.ts b/src/lib/settings/settings.ts index f8a22f2..b735e1a 100644 --- a/src/lib/settings/settings.ts +++ b/src/lib/settings/settings.ts @@ -1,5 +1,4 @@ import { browser } from '$app/environment'; -import { zoomDefault } from '$lib/panzoom'; import { derived, get, writable } from 'svelte/store'; export type FontSize = diff --git a/src/routes/[manga]/+page.svelte b/src/routes/[manga]/+page.svelte index 33d2996..ab9d0a1 100644 --- a/src/routes/[manga]/+page.svelte +++ b/src/routes/[manga]/+page.svelte @@ -2,7 +2,7 @@ import { catalog } from '$lib/catalog'; import { goto } from '$app/navigation'; import VolumeItem from '$lib/components/VolumeItem.svelte'; - import { Button, Listgroup, Progressbar, Spinner } from 'flowbite-svelte'; + import { Button, Listgroup } from 'flowbite-svelte'; import { db } from '$lib/catalog/db'; import { promptConfirmation, zipManga } from '$lib/util'; import { page } from '$app/stores'; @@ -77,7 +77,7 @@

Minutes read: {stats.timeReadInMinutes}

-
+