blob: 2ca117a803e1fde72fed745f88baf278851bd661 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<!--
A dialog (the reference app's MenuCard): a centered card over a dimmed
backdrop with a Close button. The parent renders its content via the
`children` slot (Svelte 5 render-prop form).
-->
<script lang="ts">
import type { Snippet } from 'svelte';
import { t } from '$lib/i18n';
let {
open = $bindable(true),
title = '',
children
}: {
open?: boolean;
title?: string;
children?: Snippet;
} = $props();
function close() {
open = false;
}
</script>
{#if open}
<div class="dialog__overlay" role="dialog" aria-modal="true">
<div class="dialog__card">
{#if title}
<div class="dialog__title">{title}</div>
{/if}
<div class="dialog__body">
{@render children?.()}
</div>
<div class="dialog__footer">
<button class="dialog__close" onclick={close}>{t('close')}</button>
</div>
</div>
</div>
{/if}
|