budibase/packages/builder/src/common/Modal.svelte

41 lines
663 B
Svelte
Raw Normal View History

2019-07-13 11:35:57 +02:00
<script>
import UIkit from "uikit";
export let isOpen = false;
export let onClosed = () => {};
export let id = "";
2019-07-13 11:35:57 +02:00
let ukModal;
let listenerAdded = false;
$: {
2019-11-03 11:24:48 +01:00
if(ukModal && !listenerAdded) {
listenerAdded = true;
ukModal.addEventListener("hide", onClosed);
}
2019-07-13 11:35:57 +02:00
if(ukModal) {
if(isOpen) {
UIkit.modal(ukModal).show();
} else {
UIkit.modal(ukModal).hide();
}
}
}
</script>
<div bind:this={ukModal} uk-modal {id}>
2019-07-13 11:35:57 +02:00
<div class="uk-modal-dialog uk-modal-body" uk-overflow-auto>
<slot />
</div>
</div>
<style>
.uk-modal-dialog {
border-radius: .3rem;
}
2019-07-13 11:35:57 +02:00
</style>