aboutsummaryrefslogtreecommitdiff
path: root/src_frontend/Components/Dialogs/ConfirmActionDialog.svelte
blob: 185c743d7e30e44f5d4e704c094b8f34f25ec92c (plain) (blame)
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
52
53
54
55
56
57
58
59
<script>
    import { onMount } from "svelte";
	import dialogPolyfill from 'dialog-polyfill'
    import Button from "../../ComponentLib/Button/Button.svelte";
    
    export let title = "Are you sure?";
    export let text = "Are you sure you want to delete the galaxy?";
    export let defaultAction = false;
    export let action = () => console.log("No action specified");

    let modal;
    let activeTab = 0;
    let name;
    let sourceMode;

    function open() {
        modal.showModal()
    }
    function confirm() {
        modal.close();
        action();
    }
    function register(node) {
        dialogPolyfill.registerDialog(node);
    }
</script>

<style>
    dialog {
        padding: 15px;
        border: none;
        border-radius: 15px;
    }
    h2 {
        margin: 0;
    }
    .buttons {
        display: flex;
    }
    .buttons > * {
        flex-grow: 1;
    }
    .buttons > *:not(:last-child) {
        margin-right: 5px;
    }
    .buttons > *:not(:first-child) {
        margin-left: 5px;
    }
</style>

<slot name="trigger" {open}></slot>
<dialog bind:this={modal} use:register>
    <h2>{title}</h2>
    <p>{text}</p>
    <div class="buttons">
        <div><Button fullWidth=true on:click={confirm}  color={"var(--theme-primary)"} backgroundColor={"white"}>Yes</Button></div>
        <div><Button fullWidth=true on:click={() => modal.close() }>No</Button></div>
    </div>
</dialog>