2019-12-04 23:13:06 +01:00
|
|
|
<script>
|
2020-01-31 10:45:02 +01:00
|
|
|
import UIkit from "uikit";
|
2019-12-04 23:13:06 +01:00
|
|
|
|
2020-01-31 10:45:02 +01:00
|
|
|
export let isOpen = false;
|
|
|
|
export let onClosed = () => {};
|
|
|
|
export let id = "";
|
2019-12-04 23:13:06 +01:00
|
|
|
|
2020-01-31 10:45:02 +01:00
|
|
|
let ukModal;
|
|
|
|
let listenerAdded = false;
|
2019-12-04 23:13:06 +01:00
|
|
|
|
2020-01-31 10:45:02 +01:00
|
|
|
$: {
|
|
|
|
if (ukModal && !listenerAdded) {
|
|
|
|
listenerAdded = true;
|
|
|
|
ukModal.addEventListener("hidden", onClosed);
|
2019-12-04 23:13:06 +01:00
|
|
|
}
|
|
|
|
|
2020-01-31 10:45:02 +01:00
|
|
|
if (ukModal) {
|
|
|
|
if (isOpen) {
|
|
|
|
UIkit.modal(ukModal).show();
|
|
|
|
} else {
|
|
|
|
UIkit.modal(ukModal).hide();
|
|
|
|
}
|
2019-12-04 23:13:06 +01:00
|
|
|
}
|
2020-01-31 10:45:02 +01:00
|
|
|
}
|
2019-12-04 23:13:06 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2020-01-31 10:45:02 +01:00
|
|
|
.uk-modal-dialog {
|
|
|
|
border-radius: 0.3rem;
|
2020-01-30 17:22:19 +01:00
|
|
|
width: 60%;
|
2020-01-30 22:00:19 +01:00
|
|
|
height: 80vh;
|
2020-01-31 10:45:02 +01:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
</style>
|
2019-12-04 23:13:06 +01:00
|
|
|
|
2020-01-31 10:45:02 +01:00
|
|
|
<div bind:this={ukModal} uk-modal {id}>
|
|
|
|
<div class="uk-modal-dialog uk-modal-body" uk-overflow-auto>
|
|
|
|
{#if onClosed}
|
|
|
|
<button class="uk-modal-close-default" type="button" uk-close />
|
|
|
|
{/if}
|
|
|
|
<slot />
|
|
|
|
</div>
|
|
|
|
</div>
|