2018-12-22 22:09:27 +01:00
|
|
|
<script>
|
2023-02-21 12:07:33 +01:00
|
|
|
export let showModal; // boolean
|
2018-12-22 22:09:27 +01:00
|
|
|
|
2023-02-21 12:07:33 +01:00
|
|
|
let dialog; // HTMLDialogElement
|
2019-10-27 23:26:06 +01:00
|
|
|
|
2023-02-21 12:07:33 +01:00
|
|
|
$: if (dialog && showModal) dialog.showModal();
|
2019-10-27 19:44:57 +01:00
|
|
|
</script>
|
2018-12-22 22:09:27 +01:00
|
|
|
|
2023-02-21 12:07:33 +01:00
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
|
|
<dialog
|
|
|
|
bind:this={dialog}
|
|
|
|
on:close={() => (showModal = false)}
|
|
|
|
on:click|self={() => dialog.close()}
|
|
|
|
>
|
|
|
|
<div on:click|stopPropagation>
|
|
|
|
<slot name="header" />
|
|
|
|
<hr />
|
|
|
|
<slot />
|
|
|
|
<hr />
|
|
|
|
<!-- svelte-ignore a11y-autofocus -->
|
|
|
|
<button autofocus on:click={() => dialog.close()}>close modal</button>
|
|
|
|
</div>
|
|
|
|
</dialog>
|
2019-10-27 23:26:06 +01:00
|
|
|
|
2018-12-22 22:09:27 +01:00
|
|
|
<style>
|
2023-02-21 12:07:33 +01:00
|
|
|
dialog {
|
2018-12-22 22:09:27 +01:00
|
|
|
max-width: 32em;
|
|
|
|
border-radius: 0.2em;
|
2023-02-21 12:07:33 +01:00
|
|
|
border: none;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
dialog::backdrop {
|
|
|
|
background: rgba(0, 0, 0, 0.3);
|
|
|
|
}
|
|
|
|
dialog > div {
|
|
|
|
padding: 1em;
|
|
|
|
}
|
|
|
|
dialog[open] {
|
|
|
|
animation: zoom 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
|
|
}
|
|
|
|
@keyframes zoom {
|
|
|
|
from {
|
|
|
|
transform: scale(0.95);
|
|
|
|
}
|
|
|
|
to {
|
|
|
|
transform: scale(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dialog[open]::backdrop {
|
|
|
|
animation: fade 0.2s ease-out;
|
|
|
|
}
|
|
|
|
@keyframes fade {
|
|
|
|
from {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
to {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
2018-12-22 22:09:27 +01:00
|
|
|
}
|
|
|
|
button {
|
|
|
|
display: block;
|
|
|
|
}
|
2023-02-21 12:07:33 +01:00
|
|
|
</style>
|