summaryrefslogblamecommitdiffstatshomepage
path: root/frontend/src/lib/reader/Reader.svelte
blob: 15ebdf43050a049778b637f0b545f22c1cc5773a (plain) (tree)
1
2
3
4
5
6
7





                                                                              
                                                                      



















                                                                                                        
                                                                                                    




                                                            


                                                                                     






                                               
<script lang="ts">
	import { trapFocus } from '$lib/Actions';
	import { getReaderContext } from '$lib/Reader';
	import { fadeDefault, slideXDefault } from '$lib/Transitions';
	import { fade, slide } from 'svelte/transition';
	import CloseReaderButton from './components/CloseReaderButton.svelte';
	import PageIndicator from './components/PageIndicator.svelte';
	import ReaderMenuButton from './components/ReaderMenuButton.svelte';

	const reader = getReaderContext();
</script>

{#if $reader.visible}
	<div
		role="dialog"
		class="fixed bottom-0 left-0 right-0 top-0 z-10 flex h-full w-full bg-black"
		transition:fade={fadeDefault}
		use:trapFocus
	>
		{#if $$slots.sidebar && $reader.sidebar}
			<aside class="w-[36rem] shrink-0 bg-slate-800" transition:slide={slideXDefault}>
				<div class="flex h-full min-w-[36rem] flex-col gap-4 overflow-auto p-4">
					<slot name="sidebar" />
				</div>
			</aside>
		{/if}
		<main class="relative flex grow">
			<div class="absolute z-10 flex w-full p-1 text-lg [&>*:last-child]:ml-auto">
				{#if $$slots.sidebar}
					<ReaderMenuButton />
				{/if}
				<CloseReaderButton />
			</div>
			<div class="absolute bottom-0 right-0 z-10 flex p-1 text-lg">
				<PageIndicator />
			</div>

			<div class="flex grow">
				<slot />
			</div>
		</main>
	</div>
{/if}