forked from tsai/budibase
28 changed files with 377 additions and 385 deletions
@ -1,63 +0,0 @@ |
|||||
<script> |
|
||||
import { getContext } from "svelte" |
|
||||
import { Button } from "@budibase/bbui" |
|
||||
import { ContextKey } from "./context" |
|
||||
|
|
||||
export let cancelText = "Cancel" |
|
||||
export let confirmText = "Confirm" |
|
||||
export let showCancelButton = true |
|
||||
export let showConfirmButton = true |
|
||||
export let onConfirm |
|
||||
|
|
||||
const modalContext = getContext(ContextKey) |
|
||||
let loading = false |
|
||||
|
|
||||
function hide() { |
|
||||
modalContext.hide() |
|
||||
} |
|
||||
|
|
||||
async function confirm() { |
|
||||
loading = true |
|
||||
if (!onConfirm || (await onConfirm()) !== false) { |
|
||||
hide() |
|
||||
} |
|
||||
loading = false |
|
||||
} |
|
||||
</script> |
|
||||
|
|
||||
<footer> |
|
||||
<div class="content"> |
|
||||
<slot /> |
|
||||
</div> |
|
||||
<div class="buttons"> |
|
||||
{#if showCancelButton} |
|
||||
<Button secondary on:click={hide}>{cancelText}</Button> |
|
||||
{/if} |
|
||||
{#if showConfirmButton} |
|
||||
<Button |
|
||||
primary |
|
||||
{...$$restProps} |
|
||||
disabled={$$props.disabled || loading} |
|
||||
on:click={confirm}> |
|
||||
{confirmText} |
|
||||
</Button> |
|
||||
{/if} |
|
||||
</div> |
|
||||
</footer> |
|
||||
|
|
||||
<style> |
|
||||
footer { |
|
||||
display: flex; |
|
||||
flex-direction: row; |
|
||||
justify-content: space-between; |
|
||||
align-items: center; |
|
||||
gap: var(--spacing-m); |
|
||||
} |
|
||||
.buttons { |
|
||||
display: flex; |
|
||||
flex-direction: row; |
|
||||
justify-content: flex-end; |
|
||||
align-items: center; |
|
||||
gap: var(--spacing-m); |
|
||||
} |
|
||||
</style> |
|
||||
@ -1,10 +0,0 @@ |
|||||
<h5> |
|
||||
<slot /> |
|
||||
</h5> |
|
||||
|
|
||||
<style> |
|
||||
h5 { |
|
||||
margin: 0; |
|
||||
font-weight: 500; |
|
||||
} |
|
||||
</style> |
|
||||
@ -1,5 +1,3 @@ |
|||||
export { default as Modal } from "./Modal.svelte" |
export { default as Modal } from "./Modal.svelte" |
||||
export { default as ModalContainer } from "./ModalContainer.svelte" |
export { default as ModalContainer } from "./ModalContainer.svelte" |
||||
export { default as ModalTitle } from "./ModalTitle.svelte" |
|
||||
export { default as ModalFooter } from "./ModalFooter.svelte" |
|
||||
export { ContextKey } from "./context" |
export { ContextKey } from "./context" |
||||
|
|||||
Loading…
Reference in new issue