Files
pocket-id/frontend/src/lib/components/login-wrapper.svelte

81 lines
2.2 KiB
Svelte
Raw Normal View History

2024-08-12 11:00:25 +02:00
<script lang="ts">
import { browser } from '$app/environment';
import { browserSupportsWebAuthn } from '@simplewebauthn/browser';
import type { Snippet } from 'svelte';
2025-01-19 15:30:31 +01:00
import { Button } from './ui/button';
2024-08-12 11:00:25 +02:00
import * as Card from './ui/card';
import WebAuthnUnsupported from './web-authn-unsupported.svelte';
2025-01-19 15:30:31 +01:00
import { page } from '$app/stores';
2024-08-12 11:00:25 +02:00
let {
2025-01-19 15:30:31 +01:00
children,
showEmailOneTimeAccessButton = false
2024-08-12 11:00:25 +02:00
}: {
children: Snippet;
2025-01-19 15:30:31 +01:00
showEmailOneTimeAccessButton?: boolean;
2024-08-12 11:00:25 +02:00
} = $props();
</script>
2025-01-19 15:30:31 +01:00
<!-- Desktop -->
2024-08-12 11:00:25 +02:00
<div class="hidden h-screen items-center text-center lg:flex">
2025-01-19 15:30:31 +01:00
<div class="h-full min-w-[650px] p-16 {showEmailOneTimeAccessButton ? 'pb-0' : ''}">
2024-08-12 11:00:25 +02:00
{#if browser && !browserSupportsWebAuthn()}
<WebAuthnUnsupported />
{:else}
2025-01-19 15:30:31 +01:00
<div class="flex h-full flex-col">
<div class="flex flex-grow flex-col items-center justify-center">
{@render children()}
</div>
{#if showEmailOneTimeAccessButton}
<div class="mb-4 flex justify-center">
2025-01-19 15:41:16 +01:00
<Button
href="/login/email?redirect={encodeURIComponent(
$page.url.pathname + $page.url.search
)}"
variant="link"
class="text-xs text-muted-foreground"
>
2025-01-19 15:30:31 +01:00
Don't have access to your passkey?
</Button>
</div>
{/if}
</div>
2024-08-12 11:00:25 +02:00
{/if}
</div>
<img
2024-08-13 18:32:21 +02:00
src="/api/application-configuration/background-image"
2024-08-12 11:00:25 +02:00
class="h-screen w-[calc(100vw-650px)] rounded-l-[60px] object-cover"
alt="Login background"
/>
</div>
2025-01-19 15:30:31 +01:00
<!-- Mobile -->
2024-08-12 11:00:25 +02:00
<div
2024-08-13 21:06:29 +02:00
class="flex h-screen items-center justify-center bg-[url('/api/application-configuration/background-image')] bg-cover bg-center text-center lg:hidden"
2024-08-12 11:00:25 +02:00
>
<Card.Root class="mx-3">
2025-01-19 15:30:31 +01:00
<Card.CardContent
class="px-4 py-10 sm:p-10 {showEmailOneTimeAccessButton ? 'pb-3 sm:pb-3' : ''}"
>
2024-08-12 11:00:25 +02:00
{#if browser && !browserSupportsWebAuthn()}
<WebAuthnUnsupported />
{:else}
{@render children()}
2025-01-19 15:30:31 +01:00
{#if showEmailOneTimeAccessButton}
<div class="mt-5">
2025-01-19 15:41:16 +01:00
<Button
href="/login/email?redirect={encodeURIComponent(
$page.url.pathname + $page.url.search
)}"
variant="link"
class="text-xs text-muted-foreground"
>
2025-01-19 15:30:31 +01:00
Don't have access to your passkey?
</Button>
</div>
{/if}
2024-08-12 11:00:25 +02:00
{/if}
</Card.CardContent>
</Card.Root>
</div>