From 3f6bd71aaac4277d046485fe8ea2a791ea089cd8 Mon Sep 17 00:00:00 2001
From: Wolfgang Müller
Date: Tue, 18 Feb 2025 15:51:14 +0100
Subject: frontend: Migrate PageView to Svelte 5

---
 frontend/src/lib/reader/PageView.svelte | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

(limited to 'frontend/src/lib/reader/PageView.svelte')

diff --git a/frontend/src/lib/reader/PageView.svelte b/frontend/src/lib/reader/PageView.svelte
index fc45cfa..2f8def7 100644
--- a/frontend/src/lib/reader/PageView.svelte
+++ b/frontend/src/lib/reader/PageView.svelte
@@ -1,20 +1,14 @@
 <script lang="ts">
 	import { Direction, Layout, type PageFragment } from '$gql/graphql';
+	import { getReaderContext, partition } from '$lib/Reader.svelte';
 	import { binds } from '$lib/Shortcuts';
 	import { src } from '$lib/Utils';
-	import { getReaderContext, partition, type Chunk } from './Reader.svelte';
+	import PageIndicator from './components/PageIndicator.svelte';
 	import ReaderPage from './ReaderPage.svelte';
 
 	const reader = getReaderContext();
 
-	export let direction: Direction;
-	export let layout: Layout;
-
-	let chunks: Chunk[] = [];
-	let lookup: number[] = [];
-
-	let main: PageFragment;
-	let secondary: PageFragment | undefined;
+	let { direction, layout }: { direction: Direction; layout: Layout } = $props();
 
 	function gotoChunk(to: number) {
 		if (to < 0 || to >= chunks.length) return;
@@ -61,8 +55,8 @@
 		}
 	}
 
-	$: [chunks, lookup] = partition(reader.pages, layout);
-	$: layout, ({ main, secondary } = chunks[lookup[reader.page]]);
+	let [chunks, lookup] = $derived(partition(reader.pages, layout));
+	let { main, secondary } = $derived(chunks[lookup[reader.page]]);
 </script>
 
 <svelte:document
@@ -89,6 +83,9 @@
 	<ReaderPage page={secondary} onclick={next} --justify="flex-end" />
 	<ReaderPage page={main} onclick={prev} --justify="flex-start" />
 {/if}
+<div class="absolute right-0 bottom-0 z-10 flex p-1 text-lg">
+	<PageIndicator />
+</div>
 <div class="invisible absolute">
 	{#each pagesAround(reader.page) as page}
 		<img src={src(page.image, 'full')} alt="" />
-- 
cgit v1.2.3-2-gb3c3

