Studio: improve delete button

This commit is contained in:
Pieter Vander Vennet 2024-08-12 10:08:10 +02:00
parent 4e02528bdc
commit dca17742b4

View file

@ -1,10 +1,9 @@
<script lang="ts"> <script lang="ts">
import { EditJsonState } from "./EditLayerState" import { EditJsonState } from "./EditLayerState"
import BackButton from "../Base/BackButton.svelte"
import { TrashIcon } from "@rgossiaux/svelte-heroicons/solid" import { TrashIcon } from "@rgossiaux/svelte-heroicons/solid"
import NextButton from "../Base/NextButton.svelte" import NextButton from "../Base/NextButton.svelte"
import AccordionSingle from "../Flowbite/AccordionSingle.svelte"
let deleteState: "init" | "confirm" = "init"
export let backToStudio: () => void export let backToStudio: () => void
export let state: EditJsonState export let state: EditJsonState
@ -16,32 +15,28 @@
} }
</script> </script>
<div class="mt-12"> <AccordionSingle>
{#if deleteState === "init"} <div slot="header" class="flex gap-x-2">
<button <TrashIcon class="h-6 w-6" />
on:click={() => { Delete this {objectType}
deleteState = "confirm" </div>
}}
class="small" <div class="flex flex-col">
> <div>
<TrashIcon class="h-6 w-6" /> Deleting this layer will delete your version. If you clicked a layer made by someone else, their version will
Delete this {objectType} remain.
</button>
{:else if deleteState === "confirm"} If you ever accidentally delete a layer, contact Pietervdvn. He might have a backup
<div class="flex">
<BackButton
on:click={() => {
deleteState = "init"
}}
>
Don't delete
</BackButton>
<NextButton clss="primary" on:click={() => deleteLayer()}>
<div class="alert flex p-2">
<TrashIcon class="h-6 w-6" />
Do delete this {objectType}
</div>
</NextButton>
</div> </div>
{/if}
</div> <NextButton clss="primary" on:click={() => deleteLayer()}>
<div class="alert flex p-2">
<TrashIcon class="h-6 w-6" />
Do delete this {objectType}
</div>
</NextButton>
</div>
</AccordionSingle>