flotilla/src/routes/+layout.svelte

63 lines
1.4 KiB
Svelte
Raw Normal View History

2024-08-05 21:45:16 +00:00
<script lang="ts">
2024-08-06 20:10:10 +00:00
import "@src/app.css"
2024-08-09 00:22:17 +00:00
import {onMount} from 'svelte'
2024-08-05 22:28:46 +00:00
import {page} from "$app/stores"
2024-08-06 22:46:37 +00:00
import {fly} from "@lib/transition"
2024-08-08 21:02:46 +00:00
import ModalBox from "@lib/components/ModalBox.svelte"
2024-08-08 23:32:46 +00:00
import Toast from "@app/components/Toast.svelte"
2024-08-09 23:22:09 +00:00
import Landing from "@app/components/Landing.svelte"
2024-08-06 20:10:10 +00:00
import PrimaryNav from "@app/components/PrimaryNav.svelte"
import SecondaryNav from "@app/components/SecondaryNav.svelte"
2024-08-09 00:22:17 +00:00
import {modals, clearModal} from "@app/modal"
2024-08-09 23:22:09 +00:00
import {session} from "@app/base"
2024-08-05 21:45:16 +00:00
2024-08-09 00:22:17 +00:00
let dialog: HTMLDialogElement
2024-08-09 23:22:09 +00:00
$: modalId = $page.url.hash.slice(1)
$: modal = modals.get(modalId)
2024-08-05 21:45:16 +00:00
$: {
2024-08-09 23:22:09 +00:00
if (!modal && !$session) {
modal = {component: Landing}
}
2024-08-09 00:22:17 +00:00
if (modal) {
dialog?.showModal()
2024-08-05 21:45:16 +00:00
} else {
2024-08-09 00:22:17 +00:00
dialog?.close()
2024-08-05 21:45:16 +00:00
}
}
2024-08-09 00:22:17 +00:00
onMount(() => {
dialog.addEventListener('close', () => {
if (modal) {
clearModal()
}
})
})
2024-08-05 21:45:16 +00:00
</script>
2024-08-08 21:02:46 +00:00
<div data-theme="dark">
<div class="flex h-screen">
<PrimaryNav />
<SecondaryNav />
<div class="flex-grow bg-base-200">
<slot />
</div>
2024-08-05 21:45:16 +00:00
</div>
2024-08-09 00:22:17 +00:00
<dialog bind:this={dialog} class="modal modal-bottom sm:modal-middle !z-modal">
{#if modal}
{#key modal}
2024-08-09 23:22:09 +00:00
<ModalBox {...modal} />
2024-08-08 21:02:46 +00:00
{/key}
2024-08-08 23:32:46 +00:00
<Toast />
2024-08-05 21:45:16 +00:00
{/if}
2024-08-09 23:22:09 +00:00
{#if $session}
<form method="dialog" class="modal-backdrop">
<button />
</form>
{/if}
2024-08-08 21:02:46 +00:00
</dialog>
2024-08-08 23:32:46 +00:00
<Toast />
2024-08-08 21:02:46 +00:00
</div>