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

Fix margin above gr.Dataframe when no header is provided #10596

Merged
merged 7 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/short-carrots-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/dataframe": patch
"gradio": patch
---

fix:Fix margin above `gr.Dataframe` when no header is provided
4 changes: 2 additions & 2 deletions gradio/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def __init__(
show_row_numbers: bool = False,
show_search: Literal["none", "search", "filter"] = "none",
pinned_columns: int | None = None,
show_fullscreen_button: bool = True,
show_fullscreen_button: bool = False,
max_chars: int | None = None,
show_copy_button: bool = False,
):
Expand Down Expand Up @@ -765,7 +765,7 @@ def __init__(
show_row_numbers: bool = False,
show_search: Literal["none", "search", "filter"] = "none",
pinned_columns: int | None = None,
show_fullscreen_button: bool = True,
show_fullscreen_button: bool = False,
max_chars: int | None = None,
show_copy_button: bool = False,
):
Expand Down
15 changes: 15 additions & 0 deletions js/dataframe/Dataframe.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@
}}
/>

<Story
name="Dataframe without a label"
args={{
values: [
[800, 100, 800],
[200, 800, 700]
],
headers: ["Math", "Reading", "Writing"],
show_label: false,
col_count: [3, "dynamic"],
row_count: [2, "dynamic"],
editable: false
}}
/>

<Story
name="Dataframe with different colors"
args={{
Expand Down
38 changes: 20 additions & 18 deletions js/dataframe/shared/Table.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -902,24 +902,26 @@
<svelte:window on:resize={() => set_cell_widths()} />

<div class="table-container">
<div class="header-row">
{#if label && label.length !== 0 && show_label}
<div class="label">
<p>{label}</p>
</div>
{/if}
<Toolbar
{show_fullscreen_button}
{is_fullscreen}
on:click={toggle_fullscreen}
on_copy={handle_copy}
{show_copy_button}
{show_search}
on:search={(e) => handle_search(e.detail)}
on_commit_filter={commit_filter}
{current_search_query}
/>
</div>
{#if (label && label.length !== 0 && show_label) || show_fullscreen_button || show_copy_button || show_search !== "none"}
<div class="header-row">
{#if label && label.length !== 0 && show_label}
<div class="label">
<p>{label}</p>
</div>
{/if}
<Toolbar
{show_fullscreen_button}
{is_fullscreen}
on:click={toggle_fullscreen}
on_copy={handle_copy}
{show_copy_button}
{show_search}
on:search={(e) => handle_search(e.detail)}
on_commit_filter={commit_filter}
{current_search_query}
/>
</div>
{/if}
<div
bind:this={parent}
class="table-wrap"
Expand Down
Loading