54 lines
1.1 KiB
Svelte
54 lines
1.1 KiB
Svelte
<script lang="ts">
|
||||
|
|
import type { Snippet } from 'svelte';
|
|||
|
|
|
|||
|
|
let {
|
|||
|
|
children,
|
|||
|
|
description = '',
|
|||
|
|
footer,
|
|||
|
|
open = $bindable(false),
|
|||
|
|
title
|
|||
|
|
}: {
|
|||
|
|
children?: Snippet;
|
|||
|
|
description?: string;
|
|||
|
|
footer?: Snippet;
|
|||
|
|
open?: boolean;
|
|||
|
|
title: string;
|
|||
|
|
} = $props();
|
|||
|
|
|
|||
|
|
function close(): void {
|
|||
|
|
open = false;
|
|||
|
|
}
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
{#if open}
|
|||
|
|
<div
|
|||
|
|
aria-label={title}
|
|||
|
|
class="sc-dialog-backdrop"
|
|||
|
|
role="presentation"
|
|||
|
|
onclick={(event) => {
|
|||
|
|
if (event.target === event.currentTarget) close();
|
|||
|
|
}}
|
|||
|
|
>
|
|||
|
|
<section aria-modal="true" class="sc-dialog" role="dialog">
|
|||
|
|
<div class="sc-dialog-header">
|
|||
|
|
<div>
|
|||
|
|
<h2 class="sc-dialog-title">{title}</h2>
|
|||
|
|
{#if description}
|
|||
|
|
<p class="sc-dialog-description">{description}</p>
|
|||
|
|
{/if}
|
|||
|
|
</div>
|
|||
|
|
<button aria-label="Close" class="sc-dialog-close" type="button" onclick={close}>×</button>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="sc-dialog-body">
|
|||
|
|
{@render children?.()}
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
{#if footer}
|
|||
|
|
<div class="sc-dialog-footer">
|
|||
|
|
{@render footer()}
|
|||
|
|
</div>
|
|||
|
|
{/if}
|
|||
|
|
</section>
|
|||
|
|
</div>
|
|||
|
|
{/if}
|