summaryrefslogtreecommitdiffstatshomepage
path: root/frontend/src/lib/reader/Reader.svelte
blob: 0b1450abc0b220a654e2c3e32f67174d92b5bfa7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<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 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 flex w-full p-1 text-lg [&>*:last-child]:ml-auto">
				{#if $$slots.sidebar}
					<ReaderMenuButton />
				{/if}
				<CloseReaderButton />
			</div>

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