Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dataframe's upload accessibility #10478

Merged
merged 15 commits into from
Feb 4, 2025
Merged
8 changes: 8 additions & 0 deletions .changeset/tasty-humans-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@gradio/core": minor
"@gradio/dataframe": minor
"@gradio/upload": minor
"gradio": minor
---

feat:Improve dataframe's upload accessibility
3 changes: 2 additions & 1 deletion js/core/src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"delete_row": "Delete row",
"delete_column": "Delete column",
"add_column_left": "Add column to the left",
"add_column_right": "Add column to the right"
"add_column_right": "Add column to the right",
"drop_to_upload": "Drop CSV or TSV files here to import data into dataframe"
},
"dropdown": {
"dropdown": "Dropdown"
Expand Down
1 change: 1 addition & 0 deletions js/dataframe/shared/Table.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@
{root}
on:load={(e) => blob_to_string(data_uri_to_blob(e.detail.data))}
bind:dragging
aria_label="Drop CSV or TSV files here to import data into dataframe"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use i18n("dataframe.drop_to_upload") here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes we should

>
<VirtualTable
bind:items={data}
Expand Down
9 changes: 6 additions & 3 deletions js/upload/src/Upload.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<script lang="ts">
import { createEventDispatcher, tick, getContext } from "svelte";
import { createEventDispatcher, tick } from "svelte";
import type { FileData } from "@gradio/client";
import { prepare_files, type Client } from "@gradio/client";
import { _ } from "svelte-i18n";
import UploadProgress from "./UploadProgress.svelte";

export let filetype: string | string[] | null = null;
Expand All @@ -23,6 +22,7 @@
export let stream_handler: Client["stream"];
export let icon_upload = false;
export let height: number | string | undefined = undefined;
export let aria_label: string | undefined = undefined;

let upload_id: string;
let file_data: FileData[];
Expand Down Expand Up @@ -277,6 +277,7 @@
: "100%"}
tabindex={hidden ? -1 : 0}
on:click={paste_clipboard}
aria-label={aria_label || "Paste from clipboard"}
>
<slot />
</button>
Expand Down Expand Up @@ -311,10 +312,12 @@
on:drop={loadFilesFromDrop}
on:dragenter={updateDragging}
on:dragleave={updateDragging}
aria-label={aria_label || "Click to upload or drop files"}
aria-dropeffect="copy"
>
<slot />
<input
aria-label="file upload"
aria-label="File upload"
data-testid="file-upload"
type="file"
bind:this={hidden_upload}
Expand Down
Loading