aboutsummaryrefslogtreecommitdiff
path: root/src_frontend/Components/ModeList/Mode.svelte
blob: 67752c254fd4d29d44d7ddf1f9a491d6867fd3a0 (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
<script>
	import { push } from "svelte-spa-router";
    import ConfirmActionDialog from "../Dialogs/ConfirmActionDialog.svelte";
    import { authorizedSocket } from "../../stores/socketStore.js";
    import { notif } from "../../stores/notifs";
    export let id;

    function deleteMode() {
        authorizedSocket.emit("mode:delete", `user/${id}`, (res) => {
            if (!res.success) {
                notif({title: "Error", text: "Could not delete mode...", type: "danger"})
                console.log(res);
            }
        });
    }
</script>

<style>
    .wrapper {
        width: 100%;
        padding: var(--theme-padding);
        box-sizing: border-box;
        border-radius: 15px;

        display: flex;
        align-items: center;
    }
    .right {
        margin-left: auto;
    }
    button {
        border: none;
        background-color: white;
        background-color: transparent;
        border: none;
        padding: 10px;
        border-radius: 15px;
    }
    button:hover {
        background-color: var(--grey-300);
    }
    button:active {
        background-color: var(--grey-400);
    }
</style>

<div class="wrapper drop-shadow">
    {id}
    <div class="right">
        <ConfirmActionDialog title="Are you sure?" text="Are you sure you want to delete {id}" action={deleteMode}>
            <svelte:fragment slot="trigger" let:open>
                <button on:click={open}><i class="fas fa-trash"></i></button>
            </svelte:fragment>
        </ConfirmActionDialog>
        <button on:click={() => {push(`/editor/${id}`)}}><i class="fas fa-edit"></i></button>
    </div>
</div>