@gradio/uploadbutton 0.2.1 → 0.3.0
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 +16 -1
- package/Index.svelte +4 -0
- package/UploadButton.stories.svelte +80 -0
- package/package.json +4 -4
- package/shared/UploadButton.svelte +17 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @gradio/uploadbutton
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#6584](https://github.com/gradio-app/gradio/pull/6584) [`9bcb1da`](https://github.com/gradio-app/gradio/commit/9bcb1da189a9738d023ef6daad8c6c827e3f6371) - Feat: make UploadButton accept icon. Thanks [@Justin-Xiang](https://github.com/Justin-Xiang)!
|
|
8
|
+
|
|
9
|
+
## 0.2.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`71f1a1f99`](https://github.com/gradio-app/gradio/commit/71f1a1f9931489d465c2c1302a5c8d768a3cd23a)]:
|
|
14
|
+
- @gradio/client@0.8.2
|
|
15
|
+
- @gradio/button@0.2.8
|
|
16
|
+
- @gradio/upload@0.5.1
|
|
17
|
+
|
|
3
18
|
## 0.2.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -192,4 +207,4 @@ Thanks [@pngwn](https://github.com/pngwn)!
|
|
|
192
207
|
- Updated dependencies [[`61129052`](https://github.com/gradio-app/gradio/commit/61129052ed1391a75c825c891d57fa0ad6c09fc8), [`667875b2`](https://github.com/gradio-app/gradio/commit/667875b2441753e74d25bd9d3c8adedd8ede11cd), [`67265a58`](https://github.com/gradio-app/gradio/commit/67265a58027ef1f9e4c0eb849a532f72eaebde48), [`8b4eb8ca`](https://github.com/gradio-app/gradio/commit/8b4eb8cac9ea07bde31b44e2006ca2b7b5f4de36), [`37caa2e0`](https://github.com/gradio-app/gradio/commit/37caa2e0fe95d6cab8beb174580fb557904f137f)]:
|
|
193
208
|
- @gradio/client@0.2.0
|
|
194
209
|
- @gradio/upload@0.0.3
|
|
195
|
-
- @gradio/button@0.1.0
|
|
210
|
+
- @gradio/button@0.1.0
|
package/Index.svelte
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
export let root: string;
|
|
18
18
|
export let size: "sm" | "lg" = "lg";
|
|
19
19
|
export let scale: number | null = null;
|
|
20
|
+
export let icon: string | null = null;
|
|
20
21
|
export let min_width: number | undefined = undefined;
|
|
21
22
|
export let variant: "primary" | "secondary" | "stop" = "secondary";
|
|
22
23
|
export let gradio: Gradio<{
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
click: never;
|
|
26
27
|
}>;
|
|
27
28
|
export let interactive: boolean;
|
|
29
|
+
export let proxy_url: null | string = null;
|
|
28
30
|
|
|
29
31
|
$: disabled = !interactive;
|
|
30
32
|
|
|
@@ -45,12 +47,14 @@
|
|
|
45
47
|
{file_types}
|
|
46
48
|
{size}
|
|
47
49
|
{scale}
|
|
50
|
+
{icon}
|
|
48
51
|
{min_width}
|
|
49
52
|
{root}
|
|
50
53
|
{value}
|
|
51
54
|
{disabled}
|
|
52
55
|
{variant}
|
|
53
56
|
{label}
|
|
57
|
+
{proxy_url}
|
|
54
58
|
on:click={() => gradio.dispatch("click")}
|
|
55
59
|
on:change={({ detail }) => handle_event(detail, "change")}
|
|
56
60
|
on:upload={({ detail }) => handle_event(detail, "upload")}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Meta, Template, Story } from "@storybook/addon-svelte-csf";
|
|
3
|
+
import UploadButton from "./Index.svelte";
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<Meta
|
|
7
|
+
title="Components/UploadButton"
|
|
8
|
+
component={UploadButton}
|
|
9
|
+
argTypes={{
|
|
10
|
+
label: {
|
|
11
|
+
control: "text",
|
|
12
|
+
description: "The text to display on the button",
|
|
13
|
+
name: "label",
|
|
14
|
+
value: "Gradio Button"
|
|
15
|
+
},
|
|
16
|
+
variant: {
|
|
17
|
+
options: ["primary", "secondary", "stop"],
|
|
18
|
+
description: "The variant of the button",
|
|
19
|
+
control: { type: "select" },
|
|
20
|
+
defaultValue: "primary"
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
options: ["sm", "lg"],
|
|
24
|
+
description: "The size of the button",
|
|
25
|
+
control: { type: "select" },
|
|
26
|
+
defaultValue: "lg"
|
|
27
|
+
},
|
|
28
|
+
visible: {
|
|
29
|
+
options: [true, false],
|
|
30
|
+
description: "Sets the visibility of the button",
|
|
31
|
+
control: { type: "boolean" },
|
|
32
|
+
defaultValue: true
|
|
33
|
+
},
|
|
34
|
+
interactive: {
|
|
35
|
+
options: [true, false],
|
|
36
|
+
description: "If false, the button will be in a disabled state",
|
|
37
|
+
control: { type: "boolean" },
|
|
38
|
+
defaultValue: true
|
|
39
|
+
},
|
|
40
|
+
disabled: {
|
|
41
|
+
options: [true, false],
|
|
42
|
+
control: { type: "boolean" },
|
|
43
|
+
defaultValue: false
|
|
44
|
+
},
|
|
45
|
+
scale: {
|
|
46
|
+
options: [null, 0.5, 1, 2],
|
|
47
|
+
description:
|
|
48
|
+
"relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.",
|
|
49
|
+
control: { type: "select" }
|
|
50
|
+
}
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
<Template let:args>
|
|
55
|
+
<UploadButton value="Gradio Button" {...args} />
|
|
56
|
+
</Template>
|
|
57
|
+
|
|
58
|
+
<Story
|
|
59
|
+
name="Primary"
|
|
60
|
+
args={{ label: "Upload", variant: "primary", size: "lg", scale: 1 }}
|
|
61
|
+
/>
|
|
62
|
+
<Story
|
|
63
|
+
name="Secondary"
|
|
64
|
+
args={{ label: "Upload", variant: "secondary", size: "lg" }}
|
|
65
|
+
/>
|
|
66
|
+
<Story name="Stop" args={{ label: "Upload", variant: "stop", size: "lg" }} />
|
|
67
|
+
<Story
|
|
68
|
+
name="Button with external image icon"
|
|
69
|
+
args={{
|
|
70
|
+
label: "Upload",
|
|
71
|
+
icon: "https://huggingface.co/front/assets/huggingface_logo-noborder.svg"
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
<Story
|
|
75
|
+
name="Button with visible equal to false"
|
|
76
|
+
args={{
|
|
77
|
+
label: "Upload",
|
|
78
|
+
visible: false
|
|
79
|
+
}}
|
|
80
|
+
/>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/uploadbutton",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
},
|
|
14
14
|
"main": "./Index.svelte",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@gradio/button": "^0.2.
|
|
17
|
-
"@gradio/client": "^0.8.1",
|
|
16
|
+
"@gradio/button": "^0.2.9",
|
|
18
17
|
"@gradio/utils": "^0.2.0",
|
|
19
|
-
"@gradio/upload": "^0.5.
|
|
18
|
+
"@gradio/upload": "^0.5.2",
|
|
19
|
+
"@gradio/client": "^0.8.2"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { tick, createEventDispatcher } from "svelte";
|
|
3
3
|
import { BaseButton } from "@gradio/button";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
upload,
|
|
6
|
+
prepare_files,
|
|
7
|
+
type FileData,
|
|
8
|
+
get_fetchable_url_or_file
|
|
9
|
+
} from "@gradio/client";
|
|
5
10
|
|
|
6
11
|
export let elem_id = "";
|
|
7
12
|
export let elem_classes: string[] = [];
|
|
@@ -12,10 +17,13 @@
|
|
|
12
17
|
export let file_types: string[] = [];
|
|
13
18
|
export let root: string;
|
|
14
19
|
export let size: "sm" | "lg" = "lg";
|
|
20
|
+
export let icon: string | null = null;
|
|
15
21
|
export let scale: number | null = null;
|
|
16
22
|
export let min_width: number | undefined = undefined;
|
|
17
23
|
export let variant: "primary" | "secondary" | "stop" = "secondary";
|
|
18
24
|
export let disabled = false;
|
|
25
|
+
export let proxy_url: string | null = null;
|
|
26
|
+
$: icon_path = get_fetchable_url_or_file(icon, root, proxy_url);
|
|
19
27
|
|
|
20
28
|
const dispatch = createEventDispatcher();
|
|
21
29
|
|
|
@@ -95,6 +103,9 @@
|
|
|
95
103
|
{min_width}
|
|
96
104
|
{disabled}
|
|
97
105
|
>
|
|
106
|
+
{#if icon}
|
|
107
|
+
<img class="button-icon" src={icon_path} alt={`${value} icon`} />
|
|
108
|
+
{/if}
|
|
98
109
|
<slot />
|
|
99
110
|
</BaseButton>
|
|
100
111
|
|
|
@@ -102,4 +113,9 @@
|
|
|
102
113
|
.hide {
|
|
103
114
|
display: none;
|
|
104
115
|
}
|
|
116
|
+
.button-icon {
|
|
117
|
+
width: var(--text-xl);
|
|
118
|
+
height: var(--text-xl);
|
|
119
|
+
margin-right: var(--spacing-xl);
|
|
120
|
+
}
|
|
105
121
|
</style>
|