added Modal component

This commit is contained in:
Djeeberjr 2025-05-20 13:19:51 +02:00
parent a25d26473a
commit fb3c43b53c

33
web/src/lib/Modal.svelte Normal file
View File

@ -0,0 +1,33 @@
<script lang="ts">
import type { Snippet } from 'svelte';
let { children }: { children: Snippet } = $props();
let dialog: HTMLDialogElement;
export function open(){
dialog.showModal()
}
export function close(){
dialog.close();
}
</script>
<dialog
bind:this={dialog}
closedby="any"
class="bg-gradient-to-br from-blue-100 to-indigo-200 p-5 center-dialog rounded-2xl backdrop:bg-black/50 backdrop:backdrop-blur-xs"
>
{@render children?.()}
</dialog>
<style scoped>
.center-dialog {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>