|
|
@ -2,7 +2,23 @@
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
const handleClose = () => dispatch('close')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function handleKeydown(event) {
|
|
|
|
|
|
|
|
if (event.key == 'Escape') {
|
|
|
|
|
|
|
|
handleClose()
|
|
|
|
|
|
|
|
} else if (event.key == 'Tab') {
|
|
|
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let closeButton
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
|
|
|
closeButton.focus()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</cript>
|
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
<style>
|
|
|
|
.modal-background {
|
|
|
|
.modal-background {
|
|
|
@ -16,8 +32,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
.modal {
|
|
|
|
.modal {
|
|
|
|
position: absolute;
|
|
|
|
position: absolute;
|
|
|
|
left: 50%;
|
|
|
|
left: 50%; top: 50%;
|
|
|
|
top: 50%;
|
|
|
|
|
|
|
|
width: calc(100vw - 4em);
|
|
|
|
width: calc(100vw - 4em);
|
|
|
|
max-width: 32em;
|
|
|
|
max-width: 32em;
|
|
|
|
max-height: calc(100vh - 4em);
|
|
|
|
max-height: calc(100vh - 4em);
|
|
|
@ -33,7 +48,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|
|
<div class='modal-background' on:click='{() => dispatch("close")}'></div>
|
|
|
|
<div class='modal-background' on:click='{handleClose}'></div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class='modal'>
|
|
|
|
<div class='modal'>
|
|
|
|
<slot name='header'></slot>
|
|
|
|
<slot name='header'></slot>
|
|
|
@ -41,5 +56,5 @@
|
|
|
|
<slot></slot>
|
|
|
|
<slot></slot>
|
|
|
|
<hr>
|
|
|
|
<hr>
|
|
|
|
|
|
|
|
|
|
|
|
<button on:click='{() => dispatch("close")}'>close modal</button>
|
|
|
|
<button on:click='{() => dispatch("close")}' bind:this={closeButton}>close modal</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|