flotilla/src/routes/+layout.svelte

69 lines
1.6 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-05 22:28:46 +00:00
import {onMount} from "svelte"
import {page} from "$app/stores"
import {onNavigate} from "$app/navigation"
2024-08-06 20:10:10 +00:00
import {fly} from '@lib/transition'
import Icon from "@lib/components/Icon.svelte"
import {toast} from '@app/toast'
import {modals, pushModal} from '@app/modal'
import PrimaryNav from "@app/components/PrimaryNav.svelte"
import SecondaryNav from "@app/components/SecondaryNav.svelte"
2024-08-05 21:45:16 +00:00
const login = async () => {
2024-08-05 22:28:46 +00:00
const nl = await import("nostr-login")
2024-08-05 21:45:16 +00:00
nl.init({
noBanner: true,
2024-08-05 22:28:46 +00:00
title: "Welcome to Flotilla!",
description: "Log in with your Nostr account or sign up to join.",
methods: ["connect", "extension", "local"],
2024-08-05 21:45:16 +00:00
onAuth(npub: string) {
console.log(npub)
2024-08-05 22:28:46 +00:00
},
2024-08-05 21:45:16 +00:00
})
nl.launch()
}
2024-08-05 22:25:04 +00:00
let modal: HTMLDialogElement
2024-08-05 21:45:16 +00:00
$: {
if ($page.state.modal) {
modal?.showModal()
} else {
modal?.close()
}
}
</script>
<div class="flex h-screen" data-theme="dark">
<PrimaryNav />
<SecondaryNav />
2024-08-05 22:28:46 +00:00
<div class="flex-grow bg-base-200">
2024-08-05 21:45:16 +00:00
<slot />
</div>
</div>
<dialog bind:this={modal} class="modal modal-bottom sm:modal-middle">
<div class="modal-box">
{#if $page.state.modal}
{@const {component, props} = modals.get($page.state.modal)}
<svelte:component this={component} {...props} />
{/if}
</div>
<form method="dialog" class="modal-backdrop">
<button />
</form>
</dialog>
{#if $toast}
2024-08-05 22:25:04 +00:00
{#key $toast.id}
<div transition:fly class="toast">
<div class="alert">
<span>{$toast.message}</span>
</div>
2024-08-05 21:45:16 +00:00
</div>
2024-08-05 22:25:04 +00:00
{/key}
2024-08-05 21:45:16 +00:00
{/if}