1
0
Fork 0
mirror of synced 2024-09-19 18:59:06 +12:00
budibase/packages/builder/src/components/common/ConfirmDialog.svelte

58 lines
1.1 KiB
Svelte
Raw Normal View History

2020-02-19 05:51:28 +13:00
<script>
import { Modal, Button, Heading, Spacer } from "@budibase/bbui"
2020-02-25 04:00:48 +13:00
export let title = ""
export let body = ""
export let okText = "OK"
export let cancelText = "Cancel"
export let onOk = () => {}
export let onCancel = () => {}
export const show = () => {
theModal.show()
2020-02-25 04:00:48 +13:00
}
export const hide = () => {
theModal.hide()
2020-02-25 04:00:48 +13:00
}
let theModal
const cancel = () => {
hide()
onCancel()
}
const ok = () => {
const result = onOk()
2020-08-19 08:04:42 +12:00
// allow caller to return false, to cancel the "ok"
if (result === false) return
2020-02-25 04:00:48 +13:00
hide()
}
2020-02-19 05:51:28 +13:00
</script>
<Modal id={title} bind:this={theModal}>
<h2>{title}</h2>
<Spacer extraLarge />
<slot class="rows">{body}</slot>
<Spacer extraLarge />
<div class="modal-footer">
<Button red wide on:click={ok}>{okText}</Button>
<Button secondary wide on:click={cancel}>{cancelText}</Button>
2020-02-19 05:51:28 +13:00
</div>
</Modal>
2020-03-24 23:56:48 +13:00
<style>
h2 {
font-size: var(--font-size-xl);
margin: 0;
font-family: var(--font-sans);
font-weight: 600;
}
.modal-footer {
display: grid;
grid-gap: var(--spacing-s);
2020-03-28 05:58:32 +13:00
}
2020-03-24 23:56:48 +13:00
</style>