-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathConfirmModal.svelte
51 lines (42 loc) · 1.41 KB
/
ConfirmModal.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<script>
import { Modal, ModalCloseButton } from '@keenmate/svelte-adminlte';
import { createEventDispatcher } from 'svelte';
import { _ } from 'svelte-i18n';
export let confirmTitle = $_('modal.confirm.title', { default: 'Are you sure?' });
export let confirmMessage = '';
export let icon = 'fa-exclamation';
let running = false;
let wrapper_show;
let wrapper_hide;
const dispatch = createEventDispatcher();
const confirmAction = () => {
running = true;
dispatch('confirm');
};
export const show = async () => {
running = false;
wrapper_show();
};
export const hide = () => {
wrapper_hide();
running = false;
};
</script>
<Modal bind:show={wrapper_show} bind:hide={wrapper_hide}>
<svelte:fragment slot="header">
<i class="fas {icon}"></i>
{confirmTitle}
</svelte:fragment>
<p class="text-center">{@html confirmMessage}</p>
<svelte:fragment slot="actions">
<div class="d-flex justify-content-between w-100">
<ModalCloseButton>
{$_('modal.general.close', { default: 'Close' })}
</ModalCloseButton>
<button type="button" class="btn btn-danger" disabled={running} on:click={confirmAction}>
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" class:d-none={!running}></span>
{$_('modal.confirm.submit.title', { default: 'Confirm' })}
</button>
</div>
</svelte:fragment>
</Modal>