2022-01-28 05:27:12 +00:00
|
|
|
<script lang="ts">
|
2023-09-14 00:08:54 +00:00
|
|
|
import "$lib/styles/app.pcss";
|
2023-09-12 00:29:15 +00:00
|
|
|
import { onMount } from "svelte";
|
2023-12-20 01:54:39 +00:00
|
|
|
import { getFlash } from 'sveltekit-flash-message/client';
|
2023-09-12 00:29:15 +00:00
|
|
|
import toast, { Toaster } from 'svelte-french-toast';
|
2023-09-14 00:08:54 +00:00
|
|
|
import { MetaTags } from 'svelte-meta-tags';
|
2023-09-12 00:29:15 +00:00
|
|
|
import 'iconify-icon';
|
2023-11-05 06:20:34 +00:00
|
|
|
import { page } from '$app/stores';
|
|
|
|
|
import { onNavigate } from "$app/navigation";
|
2023-09-12 00:29:15 +00:00
|
|
|
import Analytics from '$lib/components/analytics.svelte';
|
2023-12-20 01:54:39 +00:00
|
|
|
import Loading from '$lib/components/Loading.svelte';
|
2023-09-12 00:29:15 +00:00
|
|
|
import { theme } from '$state/theme';
|
2023-11-05 06:20:34 +00:00
|
|
|
import PageLoadingIndicator from '$lib/page_loading_indicator.svelte';
|
2023-09-12 00:29:15 +00:00
|
|
|
|
|
|
|
|
const dev = process.env.NODE_ENV !== 'production';
|
|
|
|
|
|
|
|
|
|
export let data;
|
|
|
|
|
$: ({ user } = data);
|
|
|
|
|
|
2023-09-14 00:08:54 +00:00
|
|
|
$: metaTags = {
|
|
|
|
|
titleTemplate: '%s | Bored Game',
|
|
|
|
|
description: 'Bored Game, keep track of your games.',
|
|
|
|
|
openGraph: {
|
|
|
|
|
type: 'website',
|
|
|
|
|
titleTemplate: '%s | Bored Game',
|
|
|
|
|
locale: 'en_US',
|
|
|
|
|
description: 'Bored Game, keep track of your games',
|
|
|
|
|
},
|
|
|
|
|
...$page.data.metaTagsChild
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-20 01:54:39 +00:00
|
|
|
const flash = getFlash(page, {
|
|
|
|
|
clearAfterMs: 6000
|
|
|
|
|
});
|
2023-09-12 00:29:15 +00:00
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
// set the theme to the user's active theme
|
|
|
|
|
$theme = user?.theme || 'system';
|
|
|
|
|
document.querySelector('html')?.setAttribute('data-theme', $theme);
|
|
|
|
|
});
|
|
|
|
|
|
2023-12-20 01:54:39 +00:00
|
|
|
flash.subscribe(($flash) => {
|
|
|
|
|
if (!$flash) return;
|
2023-11-05 00:03:28 +00:00
|
|
|
|
2023-12-20 01:54:39 +00:00
|
|
|
if ($flash.type === 'success') {
|
|
|
|
|
toast.success($flash.message);
|
|
|
|
|
} else {
|
|
|
|
|
toast.error($flash.message, {
|
|
|
|
|
duration: 5000
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-11-05 00:03:28 +00:00
|
|
|
|
2023-12-20 01:54:39 +00:00
|
|
|
// Clearing the flash message could sometimes
|
|
|
|
|
// be required here to avoid double-toasting.
|
|
|
|
|
flash.set(undefined);
|
|
|
|
|
});
|
2023-11-05 06:20:34 +00:00
|
|
|
|
|
|
|
|
onNavigate(async (navigation) => {
|
|
|
|
|
if (!document.startViewTransition) return;
|
|
|
|
|
|
|
|
|
|
return new Promise((oldStateCaptureResolve) => {
|
|
|
|
|
document.startViewTransition(async () => {
|
|
|
|
|
oldStateCaptureResolve();
|
|
|
|
|
await navigation.complete;
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
});
|
2022-01-28 05:27:12 +00:00
|
|
|
</script>
|
|
|
|
|
|
2023-09-12 00:29:15 +00:00
|
|
|
{#if !dev}
|
|
|
|
|
<Analytics />
|
|
|
|
|
{/if}
|
|
|
|
|
|
2023-09-14 00:08:54 +00:00
|
|
|
<MetaTags {...metaTags} />
|
|
|
|
|
|
2023-11-05 06:20:34 +00:00
|
|
|
<PageLoadingIndicator />
|
|
|
|
|
|
2023-09-12 00:29:15 +00:00
|
|
|
<div class="layout">
|
2023-09-11 22:15:53 +00:00
|
|
|
<slot />
|
2023-09-12 00:29:15 +00:00
|
|
|
</div>
|
|
|
|
|
|
2023-12-20 01:54:39 +00:00
|
|
|
<Toaster />
|
|
|
|
|
<Loading />
|
2023-09-12 00:29:15 +00:00
|
|
|
|
|
|
|
|
<style lang="postcss">
|
|
|
|
|
.layout {
|
|
|
|
|
display: flex;
|
|
|
|
|
position: relative;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
min-height: 100vh;
|
|
|
|
|
}
|
|
|
|
|
</style>
|