summaryrefslogtreecommitdiffstatshomepage
path: root/frontend/src/routes/+page.svelte
blob: 97a7a605bcfb3ee88fcb4098f5d7b3585ad12327 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<script lang="ts">
	import { version } from '$app/environment';
	import { frontpageQuery } from '$gql/Queries';
	import { ComicSort, SortDirection } from '$gql/graphql';
	import { codename } from '$lib/Meta';
	import { href } from '$lib/Navigation';
	import { fadeDefault } from '$lib/Transitions';
	import logo from '$lib/assets/logo.webp';
	import Card, { comicCard } from '$lib/components/Card.svelte';
	import Guard from '$lib/components/Guard.svelte';
	import Head from '$lib/components/Head.svelte';
	import Carousel from '$lib/containers/Carousel.svelte';
	import { getContextClient } from '@urql/svelte';
	import { fade } from 'svelte/transition';

	const bookmarkLink = href('comics', { filter: { include: { bookmarked: true } } });
	const recentLink = href('comics', {
		sort: { on: ComicSort.CreatedAt, direction: SortDirection.Descending }
	});
	const favouriteLink = href('comics', { filter: { include: { favourite: true } } });

	$: query = frontpageQuery(getContextClient());
	$: recent = $query.data?.recent;
	$: favourites = $query.data?.favourites;
	$: bookmarked = $query.data?.bookmarked;
</script>

<Head section="Home" />

<div class="flex flex-col justify-center gap-16 xl:flex-row">
	{#if $query.data}
		<div class="flex flex-col items-center gap-1">
			<img src={logo} width="512" height="512" class="min-w-[400px]" alt="" />
			<h1 class="text-4xl font-medium">
				<span>hircine</span>
				<span>{version}</span>
			</h1>
			<h2 class="text-2xl font-light text-zinc-400">{codename}</h2>
		</div>
		<div class="flex flex-col gap-8" in:fade={fadeDefault}>
			{#if recent && recent.count > 0}
				<Carousel title="Recently added" href={recentLink}>
					{#each recent.edges as comic}
						<Card coverOnly {...comicCard(comic)} />
					{/each}
				</Carousel>
			{/if}
			{#if favourites && favourites.count > 0}
				<Carousel title="Favourites" href={favouriteLink}>
					{#each favourites.edges as comic}
						<Card coverOnly {...comicCard(comic)} />
					{/each}
				</Carousel>
			{/if}
			{#if bookmarked && bookmarked.count > 0}
				<Carousel title="Bookmarks" href={bookmarkLink}>
					{#each bookmarked.edges as comic}
						<Card coverOnly {...comicCard(comic)} />
					{/each}
				</Carousel>
			{/if}
		</div>
	{:else}
		<Guard result={query} />
	{/if}
</div>