Files
varo-website/src/components/popup/Popup.svelte
bytedream 60f3f8a096
Some checks failed
deploy / build-and-deploy (push) Failing after 21s
initial commit
2025-05-18 13:16:20 +02:00

34 lines
983 B
Svelte

<script lang="ts">
import { popupState } from '@components/popup/Popup.ts';
import { onDestroy } from 'svelte';
// html bindings
let modal: HTMLDialogElement;
// lifecycle
const cancel = popupState.subscribe((value) => {
if (value) modal.show();
});
onDestroy(cancel);
// callbacks
function onModalClose() {
setTimeout(() => ($popupState = null), 300);
}
</script>
<dialog class="modal" bind:this={modal} onclose={onModalClose}>
<form method="dialog" class="modal-box">
<button class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2"></button>
<div>
<h3 class="text-lg font-geist">{$popupState?.title}</h3>
<p class="py-4 whitespace-pre-line">{$popupState?.message}</p>
<button class="btn" class:btn-error={$popupState?.type === 'error'}>Ok</button>
</div>
</form>
<form method="dialog" class="modal-backdrop bg-[rgba(0,0,0,.3)]">
<button class="!cursor-default">close</button>
</form>
</dialog>