Skip to content

Commit

Permalink
show label in interative image editor
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahblair committed Jan 30, 2024
1 parent e3217b4 commit be5ed49
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions js/imageeditor/ImageEditor.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
sources: ["webcam", "upload"],
type: "pil",
interactive: "true",
label: "Image Editor",
show_label: true,
brush: {
default_size: "auto",
colors: ["#ff0000", "#00ff00", "#0000ff"],
Expand Down
2 changes: 2 additions & 0 deletions js/imageeditor/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@
bind:this={editor_instance}
{root}
{sources}
{label}
{show_label}
on:save={(e) => handle_save()}
on:edit={() => gradio.dispatch("edit")}
on:clear={() => gradio.dispatch("clear")}
Expand Down
4 changes: 0 additions & 4 deletions js/imageeditor/shared/Controls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,4 @@
gap: var(--spacing-sm);
z-index: var(--layer-5);
}
.save :global(svg) {
transform: translateY(1px);
}
</style>
9 changes: 9 additions & 0 deletions js/imageeditor/shared/InteractiveImageEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@
export let brush: IBrush | null;
export let eraser: Eraser | null;
import { Tools, Crop, Brush, Sources } from "./tools";
import { BlockLabel } from "@gradio/atoms";
import { Image as ImageIcon } from "@gradio/icons";
export let sources: ("clipboard" | "webcam" | "upload")[];
export let crop_size: [number, number] | `${string}:${string}` | null = null;
export let i18n: I18nFormatter;
export let root: string;
export let proxy_url: string;
export let label: string | undefined = undefined;
export let show_label: boolean;
export let changeable = false;
export let value: EditorData | null = {
background: null,
Expand Down Expand Up @@ -111,6 +115,11 @@
: editor.set_tool("draw"));
</script>

<BlockLabel
{show_label}
Icon={ImageIcon}
label={label || i18n("image.image")}
/>
<ImageEditor
bind:this={editor}
{changeable}
Expand Down

0 comments on commit be5ed49

Please sign in to comment.