Image editor

This commit is contained in:
space-nuko
2023-05-13 14:54:07 -05:00
parent 4d90623505
commit f66df94c36
9 changed files with 272 additions and 123 deletions

View File

@@ -1,7 +1,10 @@
<script lang="ts">
import { Button } from "@gradio/button";
import { createEventDispatcher } from "svelte";
export let showModal; // boolean
export let closeOnClick = true; // boolean
export let showCloseButton = true; // boolean
let dialog; // HTMLDialogElement
@@ -11,7 +14,17 @@
$: if (dialog && showModal) dialog.showModal();
function close() {
function close(e: Event) {
if (!closeOnClick) {
e.preventDefault();
e.stopPropagation();
return false
}
doClose()
}
function doClose() {
dialog.close();
dispatch("close")
}
@@ -21,13 +34,16 @@
<dialog
bind:this={dialog}
on:close={close}
on:cancel={doClose}
on:click|self={close}
>
<div on:click|stopPropagation>
<slot name="header" />
<slot />
<!-- svelte-ignore a11y-autofocus -->
<button autofocus on:click={close}>Close</button>
{#if showCloseButton}
<Button variant="secondary" on:click={doClose}>Close</Button>
{/if}
</div>
</dialog>