Files
console/src/lib/components/modal.svelte
T
2022-01-15 22:56:08 +01:00

32 lines
517 B
Svelte

<script lang="ts">
export let show = false;
const handleKeydown = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
event.preventDefault();
show = false;
}
};
</script>
<svelte:window on:keydown={handleKeydown} />
{#if show}
<dialog open>
<article>
<header>
<span on:click={() => (show = false)} aria-label="Close" title="Close" class="close" />
<slot name="header" />
</header>
<slot />
</article>
</dialog>
{/if}
<style>
span.close {
cursor: pointer;
}
</style>