@gradio/imageeditor 0.11.0-beta.1 → 0.11.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -9
- package/Index.svelte +5 -3
- package/dist/Index.svelte +3 -4
- package/dist/shared/Controls.svelte +37 -59
- package/dist/shared/ImageEditor.svelte +1 -2
- package/dist/shared/tools/IconButton.svelte +133 -0
- package/dist/shared/tools/IconButton.svelte.d.ts +31 -0
- package/dist/shared/tools/Sources.svelte +1 -1
- package/dist/shared/tools/Tools.svelte +2 -1
- package/package.json +10 -10
- package/shared/Controls.svelte +37 -59
- package/shared/ImageEditor.svelte +1 -2
- package/shared/tools/IconButton.svelte +133 -0
- package/shared/tools/Sources.svelte +1 -1
- package/shared/tools/Tools.svelte +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @gradio/imageeditor
|
|
2
2
|
|
|
3
|
+
## 0.11.0-beta.3
|
|
4
|
+
|
|
5
|
+
### Dependency updates
|
|
6
|
+
|
|
7
|
+
- @gradio/upload@0.13.0-beta.3
|
|
8
|
+
- @gradio/client@1.6.0-beta.3
|
|
9
|
+
- @gradio/image@0.16.0-beta.3
|
|
10
|
+
|
|
11
|
+
## 0.11.0-beta.2
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- [#9339](https://github.com/gradio-app/gradio/pull/9339) [`4c8c6f2`](https://github.com/gradio-app/gradio/commit/4c8c6f2fe603081941c5fdc43f48a0632b9f31ad) - Ssr part 2. Thanks @pngwn!
|
|
16
|
+
- [#9250](https://github.com/gradio-app/gradio/pull/9250) [`350b0a5`](https://github.com/gradio-app/gradio/commit/350b0a5cafb9176f914f62e7c90de51d4352cc77) - Improve Icon Button consistency. Thanks @hannahblair!
|
|
17
|
+
- [#9371](https://github.com/gradio-app/gradio/pull/9371) [`7bf3e99`](https://github.com/gradio-app/gradio/commit/7bf3e9989392b7edcdc18c1d840fb8130b15040e) - Fix `gr.ImageEditor` toolbar cutoff. Thanks @hannahblair!
|
|
18
|
+
|
|
19
|
+
### Dependency updates
|
|
20
|
+
|
|
21
|
+
- @gradio/atoms@0.9.0-beta.2
|
|
22
|
+
- @gradio/upload@0.13.0-beta.2
|
|
23
|
+
- @gradio/wasm@0.14.0-beta.2
|
|
24
|
+
- @gradio/client@1.6.0-beta.2
|
|
25
|
+
- @gradio/icons@0.8.0-beta.2
|
|
26
|
+
- @gradio/statustracker@0.8.0-beta.2
|
|
27
|
+
- @gradio/utils@0.7.0-beta.2
|
|
28
|
+
- @gradio/image@0.16.0-beta.2
|
|
29
|
+
|
|
3
30
|
## 0.11.0-beta.1
|
|
4
31
|
|
|
5
32
|
### Features
|
|
@@ -18,7 +45,11 @@
|
|
|
18
45
|
- @gradio/upload@0.12.4-beta.1
|
|
19
46
|
- @gradio/wasm@0.13.1-beta.1
|
|
20
47
|
|
|
21
|
-
## 0.10.1
|
|
48
|
+
## 0.10.1
|
|
49
|
+
|
|
50
|
+
### Features
|
|
51
|
+
|
|
52
|
+
- [#9187](https://github.com/gradio-app/gradio/pull/9187) [`5bf00b7`](https://github.com/gradio-app/gradio/commit/5bf00b7524ebf399b48719120a49d15bb21bd65c) - make all component SSR compatible. Thanks @pngwn!
|
|
22
53
|
|
|
23
54
|
### Fixes
|
|
24
55
|
|
|
@@ -26,14 +57,14 @@
|
|
|
26
57
|
|
|
27
58
|
### Dependency updates
|
|
28
59
|
|
|
29
|
-
- @gradio/utils@0.
|
|
30
|
-
- @gradio/statustracker@0.
|
|
31
|
-
- @gradio/atoms@0.8.1
|
|
32
|
-
- @gradio/
|
|
33
|
-
- @gradio/
|
|
34
|
-
- @gradio/
|
|
35
|
-
- @gradio/
|
|
36
|
-
- @gradio/image@0.
|
|
60
|
+
- @gradio/utils@0.6.1
|
|
61
|
+
- @gradio/statustracker@0.7.6
|
|
62
|
+
- @gradio/atoms@0.8.1
|
|
63
|
+
- @gradio/icons@0.7.2
|
|
64
|
+
- @gradio/wasm@0.13.1
|
|
65
|
+
- @gradio/client@1.5.2
|
|
66
|
+
- @gradio/upload@0.12.4
|
|
67
|
+
- @gradio/image@0.15.1
|
|
37
68
|
|
|
38
69
|
## 0.10.0
|
|
39
70
|
|
package/Index.svelte
CHANGED
|
@@ -91,7 +91,9 @@
|
|
|
91
91
|
|
|
92
92
|
$: value && handle_change();
|
|
93
93
|
const is_browser = typeof window !== "undefined";
|
|
94
|
-
const raf = is_browser
|
|
94
|
+
const raf = is_browser
|
|
95
|
+
? window.requestAnimationFrame
|
|
96
|
+
: (cb: (...args: any[]) => void) => cb();
|
|
95
97
|
|
|
96
98
|
function wait_for_next_frame(): Promise<void> {
|
|
97
99
|
return new Promise((resolve) => {
|
|
@@ -216,8 +218,8 @@
|
|
|
216
218
|
accept_blobs={server.accept_blobs}
|
|
217
219
|
{layers}
|
|
218
220
|
status={loading_status?.status}
|
|
219
|
-
upload={gradio.client.upload}
|
|
220
|
-
stream_handler={gradio.client.stream}
|
|
221
|
+
upload={(...args) => gradio.client.upload(...args)}
|
|
222
|
+
stream_handler={(...args) => gradio.client.stream(...args)}
|
|
221
223
|
{placeholder}
|
|
222
224
|
></InteractiveImageEditor>
|
|
223
225
|
</Block>
|
package/dist/Index.svelte
CHANGED
|
@@ -58,8 +58,7 @@ let dragging;
|
|
|
58
58
|
$:
|
|
59
59
|
value && handle_change();
|
|
60
60
|
const is_browser = typeof window !== "undefined";
|
|
61
|
-
const raf = is_browser ? window.requestAnimationFrame : () =>
|
|
62
|
-
};
|
|
61
|
+
const raf = is_browser ? window.requestAnimationFrame : (cb) => cb();
|
|
63
62
|
function wait_for_next_frame() {
|
|
64
63
|
return new Promise((resolve) => {
|
|
65
64
|
raf(() => raf(() => resolve()));
|
|
@@ -176,8 +175,8 @@ $:
|
|
|
176
175
|
accept_blobs={server.accept_blobs}
|
|
177
176
|
{layers}
|
|
178
177
|
status={loading_status?.status}
|
|
179
|
-
upload={gradio.client.upload}
|
|
180
|
-
stream_handler={gradio.client.stream}
|
|
178
|
+
upload={(...args) => gradio.client.upload(...args)}
|
|
179
|
+
stream_handler={(...args) => gradio.client.stream(...args)}
|
|
181
180
|
{placeholder}
|
|
182
181
|
></InteractiveImageEditor>
|
|
183
182
|
</Block>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
-
import { IconButton } from "@gradio/atoms";
|
|
3
|
-
import {
|
|
2
|
+
import { IconButton, IconButtonWrapper } from "@gradio/atoms";
|
|
3
|
+
import { Undo, Redo, Check, Trash } from "@gradio/icons";
|
|
4
4
|
export let can_undo = false;
|
|
5
5
|
export let can_redo = false;
|
|
6
6
|
export let can_save = false;
|
|
@@ -8,66 +8,44 @@ export let changeable = false;
|
|
|
8
8
|
const dispatch = createEventDispatcher();
|
|
9
9
|
</script>
|
|
10
10
|
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
<IconButton
|
|
14
|
-
disabled={!can_undo}
|
|
15
|
-
Icon={Undo}
|
|
16
|
-
label="Undo"
|
|
17
|
-
on:click={(event) => {
|
|
18
|
-
dispatch("undo");
|
|
19
|
-
event.stopPropagation();
|
|
20
|
-
}}
|
|
21
|
-
/>
|
|
22
|
-
<IconButton
|
|
23
|
-
disabled={!can_redo}
|
|
24
|
-
Icon={Redo}
|
|
25
|
-
label="Redo"
|
|
26
|
-
on:click={(event) => {
|
|
27
|
-
dispatch("redo");
|
|
28
|
-
event.stopPropagation();
|
|
29
|
-
}}
|
|
30
|
-
/>
|
|
11
|
+
<IconButtonWrapper>
|
|
12
|
+
{#if changeable}
|
|
31
13
|
<IconButton
|
|
32
|
-
|
|
33
|
-
|
|
14
|
+
disabled={!can_save}
|
|
15
|
+
Icon={Check}
|
|
16
|
+
label="Save changes"
|
|
34
17
|
on:click={(event) => {
|
|
35
|
-
dispatch("
|
|
18
|
+
dispatch("save");
|
|
36
19
|
event.stopPropagation();
|
|
37
20
|
}}
|
|
21
|
+
background={"var(--color-green-500)"}
|
|
22
|
+
color={"#fff"}
|
|
38
23
|
/>
|
|
39
|
-
</div>
|
|
40
|
-
{#if changeable}
|
|
41
|
-
<div class="row-wrap save">
|
|
42
|
-
<IconButton
|
|
43
|
-
disabled={!can_save}
|
|
44
|
-
Icon={Check}
|
|
45
|
-
label="Save changes"
|
|
46
|
-
on:click={(event) => {
|
|
47
|
-
dispatch("save");
|
|
48
|
-
event.stopPropagation();
|
|
49
|
-
}}
|
|
50
|
-
background={"var(--color-green-500)"}
|
|
51
|
-
color={"#fff"}
|
|
52
|
-
/>
|
|
53
|
-
</div>
|
|
54
24
|
{/if}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
25
|
+
<IconButton
|
|
26
|
+
disabled={!can_undo}
|
|
27
|
+
Icon={Undo}
|
|
28
|
+
label="Undo"
|
|
29
|
+
on:click={(event) => {
|
|
30
|
+
dispatch("undo");
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
34
|
+
<IconButton
|
|
35
|
+
disabled={!can_redo}
|
|
36
|
+
Icon={Redo}
|
|
37
|
+
label="Redo"
|
|
38
|
+
on:click={(event) => {
|
|
39
|
+
dispatch("redo");
|
|
40
|
+
event.stopPropagation();
|
|
41
|
+
}}
|
|
42
|
+
/>
|
|
43
|
+
<IconButton
|
|
44
|
+
Icon={Trash}
|
|
45
|
+
label="Clear canvas"
|
|
46
|
+
on:click={(event) => {
|
|
47
|
+
dispatch("remove_image");
|
|
48
|
+
event.stopPropagation();
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
</IconButtonWrapper>
|
|
@@ -285,10 +285,9 @@ export function set_tool(tool) {
|
|
|
285
285
|
.wrap {
|
|
286
286
|
display: flex;
|
|
287
287
|
width: 100%;
|
|
288
|
-
height:
|
|
288
|
+
height: 90%;
|
|
289
289
|
position: relative;
|
|
290
290
|
justify-content: center;
|
|
291
|
-
align-items: flex-start;
|
|
292
291
|
}
|
|
293
292
|
.canvas {
|
|
294
293
|
position: absolute;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<script>import {} from "svelte";
|
|
2
|
+
export let Icon;
|
|
3
|
+
export let label = "";
|
|
4
|
+
export let show_label = false;
|
|
5
|
+
export let pending = false;
|
|
6
|
+
export let size = "small";
|
|
7
|
+
export let padded = true;
|
|
8
|
+
export let highlight = false;
|
|
9
|
+
export let disabled = false;
|
|
10
|
+
export let hasPopup = false;
|
|
11
|
+
export let color = "var(--block-label-text-color)";
|
|
12
|
+
export let transparent = false;
|
|
13
|
+
export let background = "var(--background-fill-primary)";
|
|
14
|
+
export let offset = 0;
|
|
15
|
+
$:
|
|
16
|
+
_color = highlight ? "var(--color-accent)" : color;
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<button
|
|
20
|
+
{disabled}
|
|
21
|
+
on:click
|
|
22
|
+
aria-label={label}
|
|
23
|
+
aria-haspopup={hasPopup}
|
|
24
|
+
title={label}
|
|
25
|
+
class:pending
|
|
26
|
+
class:padded
|
|
27
|
+
class:highlight
|
|
28
|
+
class:transparent
|
|
29
|
+
style:color={!disabled && _color ? _color : "var(--block-label-text-color)"}
|
|
30
|
+
style:--bg-color={!disabled ? background : "auto"}
|
|
31
|
+
style:margin-left={offset + "px"}
|
|
32
|
+
>
|
|
33
|
+
{#if show_label}<span>{label}</span>{/if}
|
|
34
|
+
<div
|
|
35
|
+
class:small={size === "small"}
|
|
36
|
+
class:large={size === "large"}
|
|
37
|
+
class:medium={size === "medium"}
|
|
38
|
+
>
|
|
39
|
+
<Icon />
|
|
40
|
+
</div>
|
|
41
|
+
</button>
|
|
42
|
+
|
|
43
|
+
<style>
|
|
44
|
+
button {
|
|
45
|
+
display: flex;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
align-items: center;
|
|
48
|
+
gap: 1px;
|
|
49
|
+
z-index: var(--layer-2);
|
|
50
|
+
/* background: var(--background-fill-primary); */
|
|
51
|
+
border-radius: var(--radius-sm);
|
|
52
|
+
color: var(--block-label-text-color);
|
|
53
|
+
border: 1px solid transparent;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
button[disabled] {
|
|
57
|
+
opacity: 0.5;
|
|
58
|
+
box-shadow: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
button[disabled]:hover {
|
|
62
|
+
cursor: not-allowed;
|
|
63
|
+
/* border: 1px solid var(--button-secondary-border-color); */
|
|
64
|
+
/* padding: 2px; */
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.padded {
|
|
68
|
+
padding: 2px;
|
|
69
|
+
background: var(--bg-color);
|
|
70
|
+
box-shadow: var(--shadow-drop);
|
|
71
|
+
border: 1px solid var(--button-secondary-border-color);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
button:hover,
|
|
75
|
+
button.highlight {
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
color: var(--color-accent);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.padded:hover {
|
|
81
|
+
border: 2px solid var(--button-secondary-border-color-hover);
|
|
82
|
+
padding: 1px;
|
|
83
|
+
color: var(--block-label-text-color);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
span {
|
|
87
|
+
padding: 0px 1px;
|
|
88
|
+
font-size: 10px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
div {
|
|
92
|
+
padding: 2px;
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: flex-end;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.small {
|
|
98
|
+
width: 14px;
|
|
99
|
+
height: 14px;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.medium {
|
|
103
|
+
width: 20px;
|
|
104
|
+
height: 20px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.large {
|
|
108
|
+
width: 22px;
|
|
109
|
+
height: 22px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.pending {
|
|
113
|
+
animation: flash 0.5s infinite;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@keyframes flash {
|
|
117
|
+
0% {
|
|
118
|
+
opacity: 0.5;
|
|
119
|
+
}
|
|
120
|
+
50% {
|
|
121
|
+
opacity: 1;
|
|
122
|
+
}
|
|
123
|
+
100% {
|
|
124
|
+
opacity: 0.5;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.transparent {
|
|
129
|
+
background: transparent;
|
|
130
|
+
border: none;
|
|
131
|
+
box-shadow: none;
|
|
132
|
+
}
|
|
133
|
+
</style>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { type ComponentType } from "svelte";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
Icon: ComponentType;
|
|
6
|
+
label?: string | undefined;
|
|
7
|
+
show_label?: boolean | undefined;
|
|
8
|
+
pending?: boolean | undefined;
|
|
9
|
+
size?: ("small" | "large" | "medium") | undefined;
|
|
10
|
+
padded?: boolean | undefined;
|
|
11
|
+
highlight?: boolean | undefined;
|
|
12
|
+
disabled?: boolean | undefined;
|
|
13
|
+
hasPopup?: boolean | undefined;
|
|
14
|
+
color?: string | undefined;
|
|
15
|
+
transparent?: boolean | undefined;
|
|
16
|
+
background?: string | undefined;
|
|
17
|
+
offset?: number | undefined;
|
|
18
|
+
};
|
|
19
|
+
events: {
|
|
20
|
+
click: MouseEvent;
|
|
21
|
+
} & {
|
|
22
|
+
[evt: string]: CustomEvent<any>;
|
|
23
|
+
};
|
|
24
|
+
slots: {};
|
|
25
|
+
};
|
|
26
|
+
export type IconButtonProps = typeof __propDef.props;
|
|
27
|
+
export type IconButtonEvents = typeof __propDef.events;
|
|
28
|
+
export type IconButtonSlots = typeof __propDef.slots;
|
|
29
|
+
export default class IconButton extends SvelteComponent<IconButtonProps, IconButtonEvents, IconButtonSlots> {
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { Upload } from "@gradio/upload";
|
|
10
10
|
import { Webcam } from "@gradio/image";
|
|
11
11
|
import {} from "@gradio/utils";
|
|
12
|
-
import { IconButton } from "
|
|
12
|
+
import { default as IconButton } from "./IconButton.svelte";
|
|
13
13
|
import {} from "@gradio/client";
|
|
14
14
|
import { add_bg_color, add_bg_image } from "./sources";
|
|
15
15
|
export let background_file;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script context="module">export const TOOL_KEY = Symbol("tool");
|
|
2
2
|
</script>
|
|
3
3
|
|
|
4
|
-
<script>import { Toolbar
|
|
4
|
+
<script>import { Toolbar } from "@gradio/atoms";
|
|
5
|
+
import { default as IconButton } from "./IconButton.svelte";
|
|
5
6
|
import { getContext, setContext } from "svelte";
|
|
6
7
|
import { writable } from "svelte/store";
|
|
7
8
|
import { EDITOR_KEY } from "../ImageEditor.svelte";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/imageeditor",
|
|
3
|
-
"version": "0.11.0-beta.
|
|
3
|
+
"version": "0.11.0-beta.3",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
"@types/tinycolor2": "^1.4.6",
|
|
11
11
|
"pixi.js": "^7.3.2",
|
|
12
12
|
"tinycolor2": "^1.6.0",
|
|
13
|
-
"@gradio/atoms": "^0.
|
|
14
|
-
"@gradio/client": "^1.6.0-beta.
|
|
15
|
-
"@gradio/
|
|
16
|
-
"@gradio/
|
|
17
|
-
"@gradio/
|
|
18
|
-
"@gradio/
|
|
19
|
-
"@gradio/
|
|
20
|
-
"@gradio/
|
|
13
|
+
"@gradio/atoms": "^0.9.0-beta.2",
|
|
14
|
+
"@gradio/client": "^1.6.0-beta.3",
|
|
15
|
+
"@gradio/icons": "^0.8.0-beta.2",
|
|
16
|
+
"@gradio/statustracker": "^0.8.0-beta.2",
|
|
17
|
+
"@gradio/utils": "^0.7.0-beta.2",
|
|
18
|
+
"@gradio/wasm": "^0.14.0-beta.2",
|
|
19
|
+
"@gradio/upload": "^0.13.0-beta.3",
|
|
20
|
+
"@gradio/image": "^0.16.0-beta.3"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@gradio/preview": "^0.11.1
|
|
23
|
+
"@gradio/preview": "^0.11.1"
|
|
24
24
|
},
|
|
25
25
|
"main_changeset": true,
|
|
26
26
|
"main": "./Index.svelte",
|
package/shared/Controls.svelte
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { createEventDispatcher } from "svelte";
|
|
3
|
-
import { IconButton } from "@gradio/atoms";
|
|
4
|
-
import {
|
|
3
|
+
import { IconButton, IconButtonWrapper } from "@gradio/atoms";
|
|
4
|
+
import { Undo, Redo, Check, Trash } from "@gradio/icons";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Can the current image be undone?
|
|
@@ -35,66 +35,44 @@
|
|
|
35
35
|
}>();
|
|
36
36
|
</script>
|
|
37
37
|
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
<IconButton
|
|
41
|
-
disabled={!can_undo}
|
|
42
|
-
Icon={Undo}
|
|
43
|
-
label="Undo"
|
|
44
|
-
on:click={(event) => {
|
|
45
|
-
dispatch("undo");
|
|
46
|
-
event.stopPropagation();
|
|
47
|
-
}}
|
|
48
|
-
/>
|
|
49
|
-
<IconButton
|
|
50
|
-
disabled={!can_redo}
|
|
51
|
-
Icon={Redo}
|
|
52
|
-
label="Redo"
|
|
53
|
-
on:click={(event) => {
|
|
54
|
-
dispatch("redo");
|
|
55
|
-
event.stopPropagation();
|
|
56
|
-
}}
|
|
57
|
-
/>
|
|
38
|
+
<IconButtonWrapper>
|
|
39
|
+
{#if changeable}
|
|
58
40
|
<IconButton
|
|
59
|
-
|
|
60
|
-
|
|
41
|
+
disabled={!can_save}
|
|
42
|
+
Icon={Check}
|
|
43
|
+
label="Save changes"
|
|
61
44
|
on:click={(event) => {
|
|
62
|
-
dispatch("
|
|
45
|
+
dispatch("save");
|
|
63
46
|
event.stopPropagation();
|
|
64
47
|
}}
|
|
48
|
+
background={"var(--color-green-500)"}
|
|
49
|
+
color={"#fff"}
|
|
65
50
|
/>
|
|
66
|
-
</div>
|
|
67
|
-
{#if changeable}
|
|
68
|
-
<div class="row-wrap save">
|
|
69
|
-
<IconButton
|
|
70
|
-
disabled={!can_save}
|
|
71
|
-
Icon={Check}
|
|
72
|
-
label="Save changes"
|
|
73
|
-
on:click={(event) => {
|
|
74
|
-
dispatch("save");
|
|
75
|
-
event.stopPropagation();
|
|
76
|
-
}}
|
|
77
|
-
background={"var(--color-green-500)"}
|
|
78
|
-
color={"#fff"}
|
|
79
|
-
/>
|
|
80
|
-
</div>
|
|
81
51
|
{/if}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
52
|
+
<IconButton
|
|
53
|
+
disabled={!can_undo}
|
|
54
|
+
Icon={Undo}
|
|
55
|
+
label="Undo"
|
|
56
|
+
on:click={(event) => {
|
|
57
|
+
dispatch("undo");
|
|
58
|
+
event.stopPropagation();
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
<IconButton
|
|
62
|
+
disabled={!can_redo}
|
|
63
|
+
Icon={Redo}
|
|
64
|
+
label="Redo"
|
|
65
|
+
on:click={(event) => {
|
|
66
|
+
dispatch("redo");
|
|
67
|
+
event.stopPropagation();
|
|
68
|
+
}}
|
|
69
|
+
/>
|
|
70
|
+
<IconButton
|
|
71
|
+
Icon={Trash}
|
|
72
|
+
label="Clear canvas"
|
|
73
|
+
on:click={(event) => {
|
|
74
|
+
dispatch("remove_image");
|
|
75
|
+
event.stopPropagation();
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
</IconButtonWrapper>
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { type ComponentType } from "svelte";
|
|
3
|
+
export let Icon: ComponentType;
|
|
4
|
+
export let label = "";
|
|
5
|
+
export let show_label = false;
|
|
6
|
+
export let pending = false;
|
|
7
|
+
export let size: "small" | "large" | "medium" = "small";
|
|
8
|
+
export let padded = true;
|
|
9
|
+
export let highlight = false;
|
|
10
|
+
export let disabled = false;
|
|
11
|
+
export let hasPopup = false;
|
|
12
|
+
export let color = "var(--block-label-text-color)";
|
|
13
|
+
export let transparent = false;
|
|
14
|
+
export let background = "var(--background-fill-primary)";
|
|
15
|
+
export let offset = 0;
|
|
16
|
+
$: _color = highlight ? "var(--color-accent)" : color;
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<button
|
|
20
|
+
{disabled}
|
|
21
|
+
on:click
|
|
22
|
+
aria-label={label}
|
|
23
|
+
aria-haspopup={hasPopup}
|
|
24
|
+
title={label}
|
|
25
|
+
class:pending
|
|
26
|
+
class:padded
|
|
27
|
+
class:highlight
|
|
28
|
+
class:transparent
|
|
29
|
+
style:color={!disabled && _color ? _color : "var(--block-label-text-color)"}
|
|
30
|
+
style:--bg-color={!disabled ? background : "auto"}
|
|
31
|
+
style:margin-left={offset + "px"}
|
|
32
|
+
>
|
|
33
|
+
{#if show_label}<span>{label}</span>{/if}
|
|
34
|
+
<div
|
|
35
|
+
class:small={size === "small"}
|
|
36
|
+
class:large={size === "large"}
|
|
37
|
+
class:medium={size === "medium"}
|
|
38
|
+
>
|
|
39
|
+
<Icon />
|
|
40
|
+
</div>
|
|
41
|
+
</button>
|
|
42
|
+
|
|
43
|
+
<style>
|
|
44
|
+
button {
|
|
45
|
+
display: flex;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
align-items: center;
|
|
48
|
+
gap: 1px;
|
|
49
|
+
z-index: var(--layer-2);
|
|
50
|
+
/* background: var(--background-fill-primary); */
|
|
51
|
+
border-radius: var(--radius-sm);
|
|
52
|
+
color: var(--block-label-text-color);
|
|
53
|
+
border: 1px solid transparent;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
button[disabled] {
|
|
57
|
+
opacity: 0.5;
|
|
58
|
+
box-shadow: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
button[disabled]:hover {
|
|
62
|
+
cursor: not-allowed;
|
|
63
|
+
/* border: 1px solid var(--button-secondary-border-color); */
|
|
64
|
+
/* padding: 2px; */
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.padded {
|
|
68
|
+
padding: 2px;
|
|
69
|
+
background: var(--bg-color);
|
|
70
|
+
box-shadow: var(--shadow-drop);
|
|
71
|
+
border: 1px solid var(--button-secondary-border-color);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
button:hover,
|
|
75
|
+
button.highlight {
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
color: var(--color-accent);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.padded:hover {
|
|
81
|
+
border: 2px solid var(--button-secondary-border-color-hover);
|
|
82
|
+
padding: 1px;
|
|
83
|
+
color: var(--block-label-text-color);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
span {
|
|
87
|
+
padding: 0px 1px;
|
|
88
|
+
font-size: 10px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
div {
|
|
92
|
+
padding: 2px;
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: flex-end;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.small {
|
|
98
|
+
width: 14px;
|
|
99
|
+
height: 14px;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.medium {
|
|
103
|
+
width: 20px;
|
|
104
|
+
height: 20px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.large {
|
|
108
|
+
width: 22px;
|
|
109
|
+
height: 22px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.pending {
|
|
113
|
+
animation: flash 0.5s infinite;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@keyframes flash {
|
|
117
|
+
0% {
|
|
118
|
+
opacity: 0.5;
|
|
119
|
+
}
|
|
120
|
+
50% {
|
|
121
|
+
opacity: 1;
|
|
122
|
+
}
|
|
123
|
+
100% {
|
|
124
|
+
opacity: 0.5;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.transparent {
|
|
129
|
+
background: transparent;
|
|
130
|
+
border: none;
|
|
131
|
+
box-shadow: none;
|
|
132
|
+
}
|
|
133
|
+
</style>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { Upload } from "@gradio/upload";
|
|
11
11
|
import { Webcam } from "@gradio/image";
|
|
12
12
|
import { type I18nFormatter } from "@gradio/utils";
|
|
13
|
-
import { IconButton } from "
|
|
13
|
+
import { default as IconButton } from "./IconButton.svelte";
|
|
14
14
|
import { type Client } from "@gradio/client";
|
|
15
15
|
|
|
16
16
|
import { add_bg_color, add_bg_image } from "./sources";
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
</script>
|
|
44
44
|
|
|
45
45
|
<script lang="ts">
|
|
46
|
-
import { Toolbar
|
|
46
|
+
import { Toolbar } from "@gradio/atoms";
|
|
47
|
+
import { default as IconButton } from "./IconButton.svelte";
|
|
47
48
|
import { getContext, setContext } from "svelte";
|
|
48
49
|
import { writable } from "svelte/store";
|
|
49
50
|
import { EDITOR_KEY, type EditorContext } from "../ImageEditor.svelte";
|