-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update gr.Dataframe UI with action popover (#9575)
* add dialog for actions * add changeset * add story * add changeset * * remove temp select column * change open dialog UX in mobile * fix border * fix test --------- Co-authored-by: gradio-pr-bot <[email protected]>
- Loading branch information
1 parent
4617e60
commit 4ec2feb
Showing
6 changed files
with
313 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@gradio/core": minor | ||
"@gradio/dataframe": minor | ||
"gradio": minor | ||
--- | ||
|
||
feat:Update gr.Dataframe UI with action popover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<script lang="ts"> | ||
export let transform: string; | ||
</script> | ||
|
||
<svg viewBox="0 0 24 24" width="16" height="16"> | ||
<path | ||
d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z" | ||
{transform} | ||
/> | ||
</svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<script lang="ts"> | ||
import { onMount } from "svelte"; | ||
import Arrow from "./Arrow.svelte"; | ||
import type { I18nFormatter } from "js/utils/src"; | ||
export let x: number; | ||
export let y: number; | ||
export let on_add_row_above: (index: number) => void; | ||
export let on_add_row_below: (index: number) => void; | ||
export let on_add_column_left: (index: number) => void; | ||
export let on_add_column_right: (index: number) => void; | ||
export let row: number; | ||
export let col: number; | ||
export let i18n: I18nFormatter; | ||
let menu_element: HTMLDivElement; | ||
onMount(() => { | ||
position_menu(); | ||
}); | ||
function position_menu(): void { | ||
if (!menu_element) return; | ||
const viewport_width = window.innerWidth; | ||
const viewport_height = window.innerHeight; | ||
const menu_rect = menu_element.getBoundingClientRect(); | ||
let new_x = x - 30; | ||
let new_y = y - 20; | ||
if (new_x + menu_rect.width > viewport_width) { | ||
new_x = x - menu_rect.width + 10; | ||
} | ||
if (new_y + menu_rect.height > viewport_height) { | ||
new_y = y - menu_rect.height + 10; | ||
} | ||
menu_element.style.left = `${new_x}px`; | ||
menu_element.style.top = `${new_y}px`; | ||
} | ||
</script> | ||
|
||
<div bind:this={menu_element} class="cell-menu"> | ||
<button on:click={() => on_add_row_above(row)}> | ||
<Arrow transform="rotate(-90 12 12)" /> | ||
{i18n("dataframe.add_row_above")} | ||
</button> | ||
<button on:click={() => on_add_row_below(row)}> | ||
<Arrow transform="rotate(90 12 12)" /> | ||
{i18n("dataframe.add_row_below")} | ||
</button> | ||
<button on:click={() => on_add_column_left(col)}> | ||
<Arrow transform="rotate(180 12 12)" /> | ||
{i18n("dataframe.add_column_left")} | ||
</button> | ||
<button on:click={() => on_add_column_right(col + 1)}> | ||
<Arrow transform="rotate(0 12 12)" /> | ||
{i18n("dataframe.add_column_right")} | ||
</button> | ||
</div> | ||
|
||
<style> | ||
.cell-menu { | ||
position: fixed; | ||
z-index: var(--layer-2); | ||
background: var(--background-fill-primary); | ||
border: 1px solid var(--border-color-primary); | ||
border-radius: var(--radius-sm); | ||
padding: var(--size-1); | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--size-1); | ||
box-shadow: var(--shadow-drop-lg); | ||
min-width: 150px; | ||
} | ||
.cell-menu button { | ||
background: none; | ||
border: none; | ||
cursor: pointer; | ||
text-align: left; | ||
padding: var(--size-1) var(--size-2); | ||
border-radius: var(--radius-sm); | ||
color: var(--body-text-color); | ||
font-size: var(--text-sm); | ||
transition: | ||
background-color 0.2s, | ||
color 0.2s; | ||
display: flex; | ||
align-items: center; | ||
gap: var(--size-2); | ||
} | ||
.cell-menu button:hover { | ||
background-color: var(--background-fill-secondary); | ||
} | ||
.cell-menu button :global(svg) { | ||
fill: currentColor; | ||
transition: fill 0.2s; | ||
} | ||
.cell-menu button:hover :global(svg) { | ||
fill: var(--color-accent); | ||
} | ||
</style> |
Oops, something went wrong.