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

60 lines
1.2 KiB
Svelte
Raw Normal View History

<script>
2020-02-03 10:50:30 +01:00
import UIkit from "uikit"
2020-02-24 16:00:48 +01:00
import ActionButton from "../common/ActionButton.svelte"
2020-02-03 10:50:30 +01:00
export let isOpen = false
export let onClosed
2020-02-03 10:50:30 +01:00
export let id = ""
export let title
2020-02-03 10:50:30 +01:00
let ukModal
let listenerAdded = false
2020-01-31 10:45:02 +01:00
$: {
if (ukModal && !listenerAdded) {
2020-02-03 10:50:30 +01:00
listenerAdded = true
ukModal.addEventListener("hidden", onClosed)
}
2020-01-31 10:45:02 +01:00
if (ukModal) {
if (isOpen) {
2020-02-03 10:50:30 +01:00
UIkit.modal(ukModal).show()
2020-01-31 10:45:02 +01:00
} else {
2020-02-03 10:50:30 +01:00
UIkit.modal(ukModal).hide()
2020-01-31 10:45:02 +01:00
}
}
2020-01-31 10:45:02 +01:00
}
</script>
2020-02-03 10:50:30 +01:00
<div bind:this={ukModal} uk-modal {id}>
{#if isOpen}
<div class="uk-modal-dialog" uk-overflow-auto>
{#if title}
<div class="uk-modal-header">
<h4 class="budibase__title--4">{title}</h4>
</div>
{/if}
<div class="uk-modal-body">
{#if onClosed}
<button class="uk-modal-close-default" type="button" uk-close />
{/if}
<slot />
</div>
2020-03-22 14:59:42 +01:00
<div class="uk-modal-footer">
<slot name="footer" />
</div>
</div>
{/if}
2020-02-03 10:50:30 +01:00
</div>
<style>
2020-01-31 10:45:02 +01:00
.uk-modal-dialog {
border-radius: 0.3rem;
width: 520px;
2020-01-30 22:00:19 +01:00
height: 80vh;
2020-01-31 10:45:02 +01:00
display: flex;
flex-direction: column;
padding: 40px;
2020-01-31 10:45:02 +01:00
}
</style>