2021-03-31 11:59:07 +02:00
|
|
|
<script>
|
2021-04-16 10:02:16 +02:00
|
|
|
import "@spectrum-css/dialog/dist/index-vars.css"
|
2021-04-08 15:46:34 +02:00
|
|
|
import { getContext } from "svelte"
|
2021-03-31 11:59:07 +02:00
|
|
|
import Button from "../Button/Button.svelte"
|
2021-04-14 14:52:25 +02:00
|
|
|
import Divider from "../Divider/Divider.svelte"
|
2021-04-21 14:59:09 +02:00
|
|
|
import Icon from "../Icon/Icon.svelte"
|
2021-03-31 11:59:07 +02:00
|
|
|
import Context from "../context"
|
|
|
|
|
|
|
|
export let title = undefined
|
2021-05-04 12:07:26 +02:00
|
|
|
export let size = "S"
|
2021-03-31 11:59:07 +02:00
|
|
|
export let cancelText = "Cancel"
|
|
|
|
export let confirmText = "Confirm"
|
|
|
|
export let showCancelButton = true
|
|
|
|
export let showConfirmButton = true
|
|
|
|
export let showCloseIcon = true
|
|
|
|
export let onConfirm = undefined
|
|
|
|
export let disabled = false
|
|
|
|
|
|
|
|
const { hide } = getContext(Context.Modal)
|
|
|
|
let loading = false
|
|
|
|
$: confirmDisabled = disabled || loading
|
|
|
|
|
|
|
|
async function confirm() {
|
|
|
|
loading = true
|
|
|
|
if (!onConfirm || (await onConfirm()) !== false) {
|
|
|
|
hide()
|
|
|
|
}
|
|
|
|
loading = false
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2021-04-15 12:50:56 +02:00
|
|
|
<div
|
2021-05-04 12:07:26 +02:00
|
|
|
class="spectrum-Dialog"
|
|
|
|
class:spectrum-Dialog--small={size === "S"}
|
|
|
|
class:spectrum-Dialog--medium={size === "M"}
|
|
|
|
class:spectrum-Dialog--large={size === "L"}
|
|
|
|
class:spectrum-Dialog--extraLarge={size === "XL"}
|
2021-04-21 14:59:09 +02:00
|
|
|
style="position: relative;"
|
2021-04-15 12:50:56 +02:00
|
|
|
role="dialog"
|
|
|
|
tabindex="-1"
|
2021-05-04 12:04:42 +02:00
|
|
|
aria-modal="true"
|
|
|
|
>
|
2021-04-08 15:46:34 +02:00
|
|
|
<div class="spectrum-Dialog-grid">
|
2021-04-16 18:12:22 +02:00
|
|
|
<h1 class="spectrum-Dialog-heading spectrum-Dialog-heading--noHeader">
|
|
|
|
{title}
|
|
|
|
</h1>
|
|
|
|
|
2021-04-27 16:25:39 +02:00
|
|
|
<Divider size="M" />
|
2021-04-08 16:05:31 +02:00
|
|
|
<!-- TODO: Remove content-grid class once Layout components are in bbui -->
|
|
|
|
<section class="spectrum-Dialog-content content-grid">
|
2021-04-08 15:46:34 +02:00
|
|
|
<slot />
|
|
|
|
</section>
|
|
|
|
{#if showCancelButton || showConfirmButton}
|
2021-04-15 12:50:56 +02:00
|
|
|
<div
|
2021-05-04 12:04:42 +02:00
|
|
|
class="spectrum-ButtonGroup spectrum-Dialog-buttonGroup spectrum-Dialog-buttonGroup--noFooter"
|
|
|
|
>
|
2021-04-15 12:50:56 +02:00
|
|
|
<slot name="footer" />
|
|
|
|
{#if showCancelButton}
|
|
|
|
<Button group secondary on:click={hide}>{cancelText}</Button>
|
|
|
|
{/if}
|
|
|
|
{#if showConfirmButton}
|
|
|
|
<Button
|
|
|
|
group
|
2021-04-09 15:24:28 +02:00
|
|
|
cta
|
2021-04-15 12:50:56 +02:00
|
|
|
{...$$restProps}
|
|
|
|
disabled={confirmDisabled}
|
2021-05-04 12:04:42 +02:00
|
|
|
on:click={confirm}
|
|
|
|
>
|
2021-04-15 12:50:56 +02:00
|
|
|
{confirmText}
|
|
|
|
</Button>
|
|
|
|
{/if}
|
2021-03-31 11:59:07 +02:00
|
|
|
</div>
|
2021-04-08 15:46:34 +02:00
|
|
|
{/if}
|
|
|
|
{#if showCloseIcon}
|
|
|
|
<div class="close-icon" on:click={hide}>
|
2021-04-23 14:03:59 +02:00
|
|
|
<Icon hoverable name="Close" />
|
2021-03-31 11:59:07 +02:00
|
|
|
</div>
|
2021-04-08 15:46:34 +02:00
|
|
|
{/if}
|
|
|
|
</div>
|
2021-03-31 11:59:07 +02:00
|
|
|
</div>
|
|
|
|
|
2021-04-08 15:46:34 +02:00
|
|
|
<style>
|
2021-05-04 12:07:26 +02:00
|
|
|
.spectrum-Dialog--extraLarge {
|
2021-05-04 11:49:33 +02:00
|
|
|
width: 1000px;
|
|
|
|
}
|
|
|
|
|
2021-04-08 16:05:31 +02:00
|
|
|
.content-grid {
|
|
|
|
display: grid;
|
|
|
|
position: relative;
|
|
|
|
gap: var(--spacing-xl);
|
|
|
|
color: var(--ink);
|
|
|
|
}
|
|
|
|
|
2021-04-15 12:50:56 +02:00
|
|
|
.spectrum-Dialog-content {
|
|
|
|
overflow: visible;
|
|
|
|
}
|
2021-04-22 14:59:00 +02:00
|
|
|
.spectrum-Dialog-heading {
|
2021-05-25 10:41:23 +02:00
|
|
|
font-family: var(--font-sans);
|
2021-04-22 14:59:00 +02:00
|
|
|
}
|
2021-04-15 12:50:56 +02:00
|
|
|
|
|
|
|
.spectrum-Dialog-buttonGroup {
|
|
|
|
gap: var(--spectrum-global-dimension-static-size-200);
|
|
|
|
}
|
|
|
|
|
2021-03-31 11:59:07 +02:00
|
|
|
.close-icon {
|
|
|
|
position: absolute;
|
2021-04-08 15:46:34 +02:00
|
|
|
top: 15px;
|
|
|
|
right: 15px;
|
2021-03-31 11:59:07 +02:00
|
|
|
color: var(--ink);
|
|
|
|
font-size: var(--font-size-m);
|
|
|
|
}
|
|
|
|
.close-icon:hover {
|
|
|
|
color: var(--grey-6);
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
.close-icon :global(svg) {
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
</style>
|