File size: 1,425 Bytes
0ad74ed |
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
<script lang="ts">
import { createEventDispatcher } from "svelte";
import { IconButton, IconButtonWrapper } from "@gradio/atoms";
import { Undo, Redo, Check, Trash } from "@gradio/icons";
/**
* Can the current image be undone?
*/
export let can_undo = false;
/**
* Can the current image be redone?
*/
export let can_redo = false;
export let can_save = false;
export let changeable = false;
const dispatch = createEventDispatcher<{
/**
* Remove the current image.
*/
remove_image: void;
/**
* Undo the last action.
*/
undo: void;
/**
* Redo the last action.
*/
redo: void;
/**
* Save the current image.
*/
save: void;
}>();
</script>
<IconButtonWrapper>
{#if changeable}
<IconButton
disabled={!can_save}
Icon={Check}
label="Save changes"
on:click={(event) => {
dispatch("save");
event.stopPropagation();
}}
background={"var(--color-green-500)"}
color={"#fff"}
/>
{/if}
<IconButton
disabled={!can_undo}
Icon={Undo}
label="Undo"
on:click={(event) => {
dispatch("undo");
event.stopPropagation();
}}
/>
<IconButton
disabled={!can_redo}
Icon={Redo}
label="Redo"
on:click={(event) => {
dispatch("redo");
event.stopPropagation();
}}
/>
<IconButton
Icon={Trash}
label="Clear canvas"
on:click={(event) => {
dispatch("remove_image");
event.stopPropagation();
}}
/>
</IconButtonWrapper>
|