Skip to content

Commit eae0082

Browse files
committed
fix
1 parent df489c1 commit eae0082

File tree

14 files changed

+674
-197
lines changed

14 files changed

+674
-197
lines changed
Loading
Loading
Loading
Loading

js/imageeditor/shared/Controls.svelte

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
Trash,
99
ZoomIn,
1010
ZoomOut,
11-
Resize as ResizeIcon
11+
Resize as ResizeIcon,
1212
} from "@gradio/icons";
1313
import type { Spring } from "svelte/motion";
1414
import Resize from "./Resize.svelte";
1515
import type { Anchor } from "./Resize.svelte";
16+
import { Pan } from "@gradio/icons";
1617
/**
1718
* Can the current image be undone?
1819
*/
@@ -26,7 +27,7 @@
2627
export let changeable = false;
2728
export let current_zoom = 1;
2829
export let dimensions: Spring<{ width: number; height: number }>;
29-
30+
export let tool: string;
3031
const dispatch = createEventDispatcher<{
3132
/**
3233
* Remove the current image.
@@ -60,6 +61,10 @@
6061
* Resize the image.
6162
*/
6263
resize: { anchor: Anchor; scale: boolean; width: number; height: number };
64+
/**
65+
* Pan the image.
66+
*/
67+
pan: void;
6368
}>();
6469
6570
let show_zoom_popup = false;
@@ -87,6 +92,19 @@
8792
</script>
8893

8994
<IconButtonWrapper>
95+
<IconButton
96+
Icon={Pan}
97+
label="Pan"
98+
on:click={(e) => {
99+
e.stopPropagation();
100+
dispatch("pan");
101+
}}
102+
highlight={tool === "pan"}
103+
size="small"
104+
padded={false}
105+
transparent={true}
106+
/>
107+
90108
<IconButton
91109
Icon={ResizeIcon}
92110
label="Resize"

js/imageeditor/shared/IconButton.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
export let transparent = false;
1414
export let background = "var(--background-fill-primary)";
1515
export let offset = 0;
16+
export let label_position: "left" | "right" = "left";
1617
$: _color = highlight ? "var(--color-accent)" : color;
1718
</script>
1819

@@ -30,14 +31,19 @@
3031
style:--bg-color={!disabled ? background : "auto"}
3132
style:margin-left={offset + "px"}
3233
>
33-
{#if show_label}<span>{label}</span>{/if}
34+
{#if show_label && label_position === "left"}
35+
<span style="margin-left: 4px;">{label}</span>
36+
{/if}
3437
<div
3538
class:small={size === "small"}
3639
class:large={size === "large"}
3740
class:medium={size === "medium"}
3841
>
3942
<Icon />
4043
</div>
44+
{#if show_label && label_position === "right"}
45+
<span style="margin-right: 4px;">{label}</span>
46+
{/if}
4147
</button>
4248

4349
<style>

0 commit comments

Comments
 (0)