🧼 Simplifies and updates color scheme for confirm
This commit is contained in:
@@ -1,61 +1,43 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { focusTrap } from 'svelte-focus-trap';
|
import { focusTrap } from 'svelte-focus-trap'
|
||||||
import { fly } from 'svelte/transition';
|
import { fly } from 'svelte/transition'
|
||||||
import { Cancel, Check } from '$lib/components/icons';
|
import { Cancel, Check } from '$lib/components/icons'
|
||||||
import { modals, exitBeforeEnter } from 'svelte-modals';
|
import { modals, exitBeforeEnter, type ModalProps } from 'svelte-modals'
|
||||||
|
|
||||||
// provided by <Modals />
|
let {
|
||||||
|
isOpen,
|
||||||
interface Props {
|
title,
|
||||||
isOpen: boolean;
|
message,
|
||||||
title: string;
|
onConfirm,
|
||||||
message: string;
|
labels = {
|
||||||
onConfirm: any;
|
cancel: { label: 'Cancel', icon: Cancel },
|
||||||
labels?: any;
|
confirm: { label: 'OK', icon: Check }
|
||||||
}
|
}
|
||||||
|
}: ModalProps = $props()
|
||||||
let {
|
|
||||||
isOpen,
|
|
||||||
title,
|
|
||||||
message,
|
|
||||||
onConfirm,
|
|
||||||
labels = {
|
|
||||||
cancel: { label: 'Cancel', icon: Cancel },
|
|
||||||
confirm: { label: 'OK', icon: Check }
|
|
||||||
}
|
|
||||||
}: Props = $props();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if isOpen}
|
{#if isOpen}
|
||||||
{@const SvelteComponent = labels?.confirm.icon}
|
{@const SvelteComponent = labels?.confirm.icon}
|
||||||
|
<div
|
||||||
|
role="dialog"
|
||||||
|
class="pointer-events-none fixed inset-0 z-50 flex items-center justify-center"
|
||||||
|
transition:fly={{ y: 50 }}
|
||||||
|
use:exitBeforeEnter
|
||||||
|
use:focusTrap>
|
||||||
<div
|
<div
|
||||||
role="dialog"
|
class="rounded-box bg-base-100 pointer-events-auto flex min-w-fit max-w-md flex-col justify-between p-4 shadow-lg">
|
||||||
class="pointer-events-none fixed inset-0 z-50 flex items-center justify-center"
|
<h2 class="text-base-content text-start text-2xl font-bold">{title}</h2>
|
||||||
transition:fly={{ y: 50 }}
|
<div class="divider my-2"></div>
|
||||||
use:exitBeforeEnter
|
<p class="text-base-content mb-1 text-start">{message}</p>
|
||||||
use:focusTrap
|
<div class="divider my-2"></div>
|
||||||
>
|
<div class="flex justify-end gap-2">
|
||||||
<div
|
<button class="btn btn-error inline-flex items-center" onclick={() => modals.close()}>
|
||||||
class="rounded-box bg-base-100 pointer-events-auto flex min-w-fit max-w-md flex-col justify-between p-4 shadow-lg"
|
<labels.cancel.icon class="mr-2 h-5 w-5" /><span>{labels?.cancel.label}</span>
|
||||||
>
|
</button>
|
||||||
<h2 class="text-base-content text-start text-2xl font-bold">{title}</h2>
|
<button class="btn btn-primary inline-flex items-center" onclick={onConfirm}>
|
||||||
<div class="divider my-2"></div>
|
<SvelteComponent class="mr-2 h-5 w-5" /><span>{labels?.confirm.label}</span>
|
||||||
<p class="text-base-content mb-1 text-start">{message}</p>
|
</button>
|
||||||
<div class="divider my-2"></div>
|
</div>
|
||||||
<div class="flex justify-end gap-2">
|
|
||||||
<button
|
|
||||||
class="btn btn-primary inline-flex items-center"
|
|
||||||
onclick={() => modals.close()}
|
|
||||||
>
|
|
||||||
<labels.cancel.icon class="mr-2 h-5 w-5" /><span>{labels?.cancel.label}</span>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="btn btn-warning text-warning-content inline-flex items-center"
|
|
||||||
onclick={onConfirm}
|
|
||||||
>
|
|
||||||
<SvelteComponent class="mr-2 h-5 w-5" /><span>{labels?.confirm.label}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user