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

Move icons into IconButtonWrapper #9261

Merged
merged 37 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fa4e40a
* update icon buttons
hannahblair Sep 3, 2024
ae78569
tweak hover
hannahblair Sep 3, 2024
8d55b50
margin tweak
hannahblair Sep 3, 2024
8eabb23
add changeset
gradio-pr-bot Sep 3, 2024
37af977
improve gr.Video button UI
hannahblair Sep 3, 2024
6b06c51
Merge branch 'update-icon-btns' of github.com:gradio-app/gradio into …
hannahblair Sep 3, 2024
71270b2
radius tweak
hannahblair Sep 3, 2024
1a19310
ensure even spacing
hannahblair Sep 3, 2024
edd8d80
fix typechecks
hannahblair Sep 3, 2024
1e4d152
add changeset
gradio-pr-bot Sep 3, 2024
7576aff
revert irrelevant changes
hannahblair Sep 3, 2024
eef2b76
Merge branch 'update-icon-btns' of github.com:gradio-app/gradio into …
hannahblair Sep 3, 2024
06c3615
typefix
hannahblair Sep 3, 2024
74acc64
fix image editor buttons
hannahblair Sep 3, 2024
952d5cc
fix download link icon
hannahblair Sep 3, 2024
9dc91ee
disable undo if no change events dispatched in model3d and video
hannahblair Sep 3, 2024
04a5329
use icons with iconbuttonwrapper
hannahblair Sep 4, 2024
4605302
add iconbuttonwrapper around gallery share btn
hannahblair Sep 4, 2024
bbf57f8
Revert "add iconbuttonwrapper around gallery share btn"
hannahblair Sep 4, 2024
caf0c86
Merge branch '5.0-dev' into chatbot-icons
hannahblair Sep 4, 2024
1471996
Merge branch '5.0-dev' into chatbot-icons
hannahblair Sep 4, 2024
8914ee2
add changeset
gradio-pr-bot Sep 4, 2024
c2b591d
Merge branch '5.0-dev' into chatbot-icons
hannahblair Sep 5, 2024
0896564
design fixes
hannahblair Sep 6, 2024
ef355fd
Merge branch 'chatbot-icons' of github.com:gradio-app/gradio into cha…
hannahblair Sep 6, 2024
daed714
add changeset
gradio-pr-bot Sep 6, 2024
f78d5ba
move status tracker progress to bottom of component
hannahblair Sep 9, 2024
199ccc4
Merge branch 'chatbot-icons' of github.com:gradio-app/gradio into cha…
hannahblair Sep 9, 2024
7bca0d6
add changeset
gradio-pr-bot Sep 9, 2024
75bd3a8
use iconbutton for like/dislike
hannahblair Sep 9, 2024
0e31ffa
Merge branch 'chatbot-icons' of github.com:gradio-app/gradio into cha…
hannahblair Sep 9, 2024
6949ee4
fix lint error
hannahblair Sep 9, 2024
ec7d8db
fix type errors
hannahblair Sep 9, 2024
1d23e8e
type errors
hannahblair Sep 9, 2024
8ed86be
fix test
hannahblair Sep 10, 2024
c46539b
revert undo icon change
hannahblair Sep 10, 2024
a107073
btn spacing
hannahblair Sep 11, 2024
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
9 changes: 9 additions & 0 deletions .changeset/every-breads-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@gradio/atoms": minor
"@gradio/chatbot": minor
"@gradio/icons": minor
"@gradio/statustracker": minor
"gradio": minor
---

feat:Move icons into `IconButtonWrapper`
6 changes: 3 additions & 3 deletions js/atoms/src/IconButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
class:large={size === "large"}
class:medium={size === "medium"}
>
<!-- handles icon reactivity -->
<svelte:component this={Icon} />
</div>
</button>
Expand All @@ -49,6 +48,7 @@
border-radius: var(--radius-xs);
color: var(--block-label-text-color);
border: 1px solid transparent;
padding: var(--spacing-xxs);
}
button:hover {
Expand Down Expand Up @@ -84,9 +84,9 @@
}
div {
padding: 2px;
display: flex;
align-items: flex-end;
align-items: center;
justify-content: center;
transition: filter 0.2s ease-in-out;
}
Expand Down
29 changes: 20 additions & 9 deletions js/atoms/src/IconButtonWrapper.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<div class="icon-button-wrapper">
<script>
export let top_panel = true;
</script>

<div class={`icon-button-wrapper ${top_panel ? "top-panel" : ""}`}>
<slot></slot>
</div>

<style>
.icon-button-wrapper {
position: absolute;
display: flex;
flex-direction: row;
top: var(--block-label-margin);
right: var(--block-label-margin);
align-items: center;
justify-content: center;
z-index: var(--layer-2);
gap: var(--spacing-sm);
box-shadow: var(--shadow-drop);
Expand All @@ -20,6 +23,18 @@
padding: var(--spacing-xxs);
}
.icon-button-wrapper:not(.top-panel) {
border: 1px solid var(--border-color-primary);
border-radius: var(--radius-sm);
}
.top-panel {
position: absolute;
top: var(--block-label-margin);
right: var(--block-label-margin);
margin: 0;
}
.icon-button-wrapper :global(button) {
margin: var(--spacing-xxs);
border-radius: var(--radius-xs);
Expand All @@ -35,14 +50,10 @@
.icon-button-wrapper :global(button:not(:last-child)::after) {
content: "";
position: absolute;
right: -5px;
right: -4.5px;
top: 15%;
height: 70%;
width: 1px;
background-color: var(--border-color-primary);
}
.icon-button-wrapper :global(a.download-link:not(:last-child)::after) {
right: -3px;
}
</style>
4 changes: 4 additions & 0 deletions js/chatbot/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,8 @@
width: 100%;
height: 100%;
}

:global(.progress-text) {
right: auto;
}
</style>
44 changes: 0 additions & 44 deletions js/chatbot/shared/ActionButton.svelte

This file was deleted.

120 changes: 40 additions & 80 deletions js/chatbot/shared/ButtonPanel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import { DownloadLink } from "@gradio/wasm/svelte";
import type { NormalisedMessage, TextMessage } from "../types";
import { is_component_message } from "./utils";
import ActionButton from "./ActionButton.svelte";
import { Retry } from "@gradio/icons";
import Remove from "./Remove.svelte";
import { Retry, Undo } from "@gradio/icons";
import { IconButtonWrapper, IconButton } from "@gradio/atoms";
export let likeable: boolean;
export let _retryable: boolean;
Expand Down Expand Up @@ -51,96 +50,57 @@

{#if show}
<div
class="message-buttons-{position} {layout} message-buttons {avatar !==
class="message-buttons-{position} {layout} message-buttons {avatar !==
null && 'with-avatar'}"
>
{#if show_copy}
<Copy value={message_text} />
{/if}
{#if show_download && !Array.isArray(message) && is_component_message(message)}
<DownloadLink
href={message?.content?.value.url}
download={message.content.value.orig_name || "image"}
>
<span class="icon-wrap">
<DownloadIcon />
</span>
</DownloadLink>
{/if}
{#if _retryable}
<ActionButton
{handle_action}
action="retry"
disabled={disable}
height={"var(--size-3)"}
>
<Retry />
</ActionButton>
{/if}
{#if _undoable}
<ActionButton
{handle_action}
action="undo"
disabled={disable}
height="var(--size-3)"
>
<Remove />
</ActionButton>
{/if}
{#if likeable}
<LikeDislike {handle_action} padded={show_copy || show_download} />
{/if}
<IconButtonWrapper top_panel={false}>
{#if show_copy}
<Copy value={message_text} />
{/if}
{#if show_download && !Array.isArray(message) && is_component_message(message)}
<DownloadLink
href={message?.content?.value.url}
download={message.content.value.orig_name || "image"}
>
<IconButton Icon={DownloadIcon} />
</DownloadLink>
{/if}
{#if _retryable}
<IconButton
Icon={Retry}
on:click={() => handle_action("retry")}
disabled={disable}
/>
{/if}
{#if _undoable}
<IconButton
Icon={Undo}
on:click={() => handle_action("undo")}
disabled={disable}
/>
{/if}
{#if likeable}
<LikeDislike {handle_action} />
{/if}
</IconButtonWrapper>
</div>
{/if}

<style>
.icon-wrap {
display: block;
color: var(--body-text-color-subdued);
}
.icon-wrap:hover {
color: var(--body-text-color);
}
.message-buttons {
border-radius: var(--radius-md);
display: flex;
align-items: center;
height: var(--size-6);
align-self: self-end;
:global(.icon-button-wrapper) {
margin: 0px calc(var(--spacing-xl) * 2);
padding-left: 5px;
z-index: 1;
padding-bottom: var(--spacing-xl);
padding: var(--spacing-md) var(--spacing-md);
border: 1px solid var(--border-color-primary);
background: var(--border-color-secondary);
gap: var(--spacing-md);
}
.message-buttons-left {
align-self: start;
left: 0px;
align-self: flex-start;
}
.panel.message-buttons-left,
.panel.message-buttons-right {
margin: 10px 0 2px 0;
.message-buttons-right {
align-self: flex-end;
}
/* .message-buttons {
left: 0px;
right: 0px;
top: unset;
bottom: calc(-30px - var(--spacing-xl));
display: flex;
justify-content: flex-start;
align-items: center;
gap: 0px;
} */
.message-buttons :global(> *) {
margin-right: 0px;
.message-buttons-right :global(.icon-button-wrapper) {
margin-left: auto;
}
.with-avatar {
Expand Down
35 changes: 8 additions & 27 deletions js/chatbot/shared/ChatBot.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
import { Image } from "@gradio/image/shared";

import { Clear, Trash, Community } from "@gradio/icons";
import { IconButtonWrapper, IconButton } from "@gradio/atoms";
import type { SelectData, LikeData } from "@gradio/utils";
import type { MessageRole } from "../types";
import { MarkdownCode as Markdown } from "@gradio/markdown";
import type { FileData, Client } from "@gradio/client";
import type { I18nFormatter } from "js/core/src/gradio_helper";
import Pending from "./Pending.svelte";
import MessageBox from "./MessageBox.svelte";
import ActionButton from "./ActionButton.svelte";
import { ShareError } from "@gradio/utils";

export let value: NormalisedMessage[] | null = [];
Expand Down Expand Up @@ -306,11 +306,11 @@
</script>

{#if value !== null && value.length > 0}
<div class="button-row">
<IconButtonWrapper>
{#if show_share_button}
<ActionButton
action="share"
handle_action={async () => {
<IconButton
Icon={Community}
on:click={async () => {
try {
// @ts-ignore
const formatted = await format_chat_for_sharing(value);
Expand All @@ -325,15 +325,13 @@
}}
>
<Community />
</ActionButton>
</IconButton>
{/if}
<ActionButton handle_action={() => dispatch("clear")} action="clear">
<Trash />
</ActionButton>
<IconButton Icon={Trash} on:click={() => dispatch("clear")}></IconButton>
{#if show_copy_all_button}
<CopyAll {value} />
{/if}
</div>
</IconButtonWrapper>
{/if}

<div
Expand Down Expand Up @@ -718,23 +716,6 @@
padding: 6px;
}

.button-row {
display: flex;
position: absolute;
right: var(--size-4);
align-items: center;
justify-content: space-evenly;
gap: var(--spacing-md);
z-index: 2;
padding-left: var(--size-2);
padding-right: var(--size-2);
background: var(--block-label-background-fill);
border-radius: var(--radius-md);
box-shadow: none;
padding-top: var(--size-1);
padding-bottom: var(--size-1);
}

.selectable {
cursor: pointer;
}
Expand Down
Loading
Loading