File size: 1,907 Bytes
0bd62e5 |
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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
<script lang="ts">
import { createEventDispatcher } from "svelte";
import { IconButton } from "@gradio/atoms";
import { Clear, 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>
<div class="controls-wrap">
<div class="row-wrap">
<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();
}}
/>
</div>
{#if changeable}
<div class="row-wrap save">
<IconButton
disabled={!can_save}
Icon={Check}
label="Save changes"
on:click={(event) => {
dispatch("save");
event.stopPropagation();
}}
background={"var(--color-green-500)"}
color={"#fff"}
/>
</div>
{/if}
</div>
<style>
.controls-wrap {
display: flex;
flex-direction: column;
gap: var(--spacing-lg);
position: absolute;
top: var(--size-2);
right: var(--size-2);
}
.row-wrap {
display: flex;
justify-content: flex-end;
gap: var(--spacing-sm);
z-index: var(--layer-5);
}
</style>
|