Skip to content

Commit

Permalink
Allow buttons to take null value (#7126)
Browse files Browse the repository at this point in the history
* allow buttons to take null value

* add changeset

* add story

* format

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
abidlabs and gradio-pr-bot committed Jan 24, 2024
1 parent 7d53aa1 commit 5727b92
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
8 changes: 8 additions & 0 deletions .changeset/all-sites-yell.md
@@ -0,0 +1,8 @@
---
"@gradio/button": patch
"@gradio/uploadbutton": patch
"@gradio/utils": patch
"gradio": patch
---

fix:Allow buttons to take null value
4 changes: 2 additions & 2 deletions js/button/Index.svelte
Expand Up @@ -10,7 +10,7 @@
export let elem_id = "";
export let elem_classes: string[] = [];
export let visible = true;
export let value: string;
export let value: string | null;
export let variant: "primary" | "secondary" | "stop" = "secondary";
export let interactive: boolean;
export let size: "sm" | "lg" = "lg";
Expand Down Expand Up @@ -41,5 +41,5 @@
disabled={!interactive}
on:click={() => gradio.dispatch("click")}
>
{gradio.i18n(value)}
{value ? gradio.i18n(value) : ""}
</Button>
4 changes: 2 additions & 2 deletions js/uploadbutton/Index.svelte
Expand Up @@ -10,7 +10,7 @@
export let elem_id = "";
export let elem_classes: string[] = [];
export let visible = true;
export let label: string;
export let label: string | null;
export let value: null | FileData | FileData[];
export let file_count: string;
export let file_types: string[] = [];
Expand Down Expand Up @@ -59,5 +59,5 @@
on:change={({ detail }) => handle_event(detail, "change")}
on:upload={({ detail }) => handle_event(detail, "upload")}
>
{gradio.i18n(label)}
{label ? gradio.i18n(label) : ""}
</UploadButton>
6 changes: 6 additions & 0 deletions js/uploadbutton/UploadButton.stories.svelte
Expand Up @@ -78,3 +78,9 @@
visible: false
}}
/>
<Story
name="Button with null label (should be collapsed)"
args={{
label: null
}}
/>
2 changes: 1 addition & 1 deletion js/uploadbutton/shared/UploadButton.svelte
Expand Up @@ -12,7 +12,7 @@
export let elem_id = "";
export let elem_classes: string[] = [];
export let visible = true;
export let label: string;
export let label: string | null;
export let value: null | FileData | FileData[];
export let file_count: string;
export let file_types: string[] = [];
Expand Down
5 changes: 0 additions & 5 deletions js/utils/src/utils.ts
Expand Up @@ -151,11 +151,6 @@ async function copy_to_clipboard(value: string): Promise<boolean> {
return copied;
}

// import { format } from "svelte-i18n";
import { get } from "svelte/store";

// const x = get(format);

export type I18nFormatter = any;
export class Gradio<T extends Record<string, any> = Record<string, any>> {
#id: number;
Expand Down

0 comments on commit 5727b92

Please sign in to comment.