2018-12-22 22:09:27 +01:00
|
|
|
<script>
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
2019-10-27 00:53:13 +02:00
|
|
|
|
|
|
|
const handleClose = () => dispatch('close')
|
|
|
|
|
|
|
|
function handleKeydown(event) {
|
|
|
|
if (event.key == 'Escape') {
|
|
|
|
handleClose()
|
|
|
|
} else if (event.key == 'Tab') {
|
|
|
|
event.preventDefault()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let closeButton
|
|
|
|
onMount(() => {
|
|
|
|
closeButton.focus()
|
|
|
|
})
|
|
|
|
|
2019-10-27 19:44:57 +01:00
|
|
|
</script>
|
2018-12-22 22:09:27 +01:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.modal-background {
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
background: rgba(0,0,0,0.3);
|
|
|
|
}
|
|
|
|
|
|
|
|
.modal {
|
|
|
|
position: absolute;
|
2019-10-27 00:53:13 +02:00
|
|
|
left: 50%; top: 50%;
|
2018-12-22 22:09:27 +01:00
|
|
|
width: calc(100vw - 4em);
|
|
|
|
max-width: 32em;
|
|
|
|
max-height: calc(100vh - 4em);
|
|
|
|
overflow: auto;
|
|
|
|
transform: translate(-50%,-50%);
|
|
|
|
padding: 1em;
|
|
|
|
border-radius: 0.2em;
|
|
|
|
background: white;
|
|
|
|
}
|
|
|
|
|
|
|
|
button {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
</style>
|
2019-03-11 03:25:33 +01:00
|
|
|
|
2019-10-27 00:53:13 +02:00
|
|
|
<div class='modal-background' on:click='{handleClose}'></div>
|
2019-03-11 03:25:33 +01:00
|
|
|
|
|
|
|
<div class='modal'>
|
|
|
|
<slot name='header'></slot>
|
|
|
|
<hr>
|
|
|
|
<slot></slot>
|
|
|
|
<hr>
|
|
|
|
|
2019-10-27 00:53:13 +02:00
|
|
|
<button on:click='{() => dispatch("close")}' bind:this={closeButton}>close modal</button>
|
2019-03-11 03:25:33 +01:00
|
|
|
</div>
|