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 17 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
17 changes: 17 additions & 0 deletions .changeset/calm-monkeys-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"@gradio/annotatedimage": minor
"@gradio/atoms": minor
"@gradio/audio": minor
"@gradio/file": minor
"@gradio/gallery": minor
"@gradio/image": minor
"@gradio/imageeditor": minor
"@gradio/json": minor
"@gradio/model3d": minor
"@gradio/simpleimage": minor
"@gradio/upload": minor
"@gradio/video": minor
"gradio": minor
---

feat:Improve Icon Button consistency
2 changes: 1 addition & 1 deletion gradio/themes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ def set(
self.block_label_right_radius = block_label_right_radius or getattr(
self,
"block_label_right_radius",
"0 calc(*radius_lg - 1px) 0 calc(*radius_lg - 1px)",
"0 calc(*radius_sm - 1px) 0 calc(*radius_sm - 1px)",
)
self.block_label_text_size = block_label_text_size or getattr(
self, "block_label_text_size", "*text_sm"
Expand Down
21 changes: 9 additions & 12 deletions js/annotatedimage/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
import type { Gradio, SelectData } from "@gradio/utils";

import { onMount } from "svelte";
import { Block, BlockLabel, Empty, IconButton } from "@gradio/atoms";
import {
Block,
BlockLabel,
Empty,
IconButton,
IconButtonWrapper
} from "@gradio/atoms";
import { Image, Maximize, Minimize } from "@gradio/icons";
import { StatusTracker } from "@gradio/statustracker";
import type { LoadingStatus } from "@gradio/statustracker";
Expand Down Expand Up @@ -159,7 +165,7 @@
<Empty size="large" unpadded_box={true}><Image /></Empty>
{:else}
<div class="image-container" bind:this={image_container}>
<div class="icon-buttons">
<IconButtonWrapper>
{#if !is_full_screen && show_fullscreen_button}
<IconButton
Icon={Maximize}
Expand All @@ -175,7 +181,7 @@
on:click={toggle_full_screen}
/>
{/if}
</div>
</IconButtonWrapper>

<img
class="base-image"
Expand Down Expand Up @@ -286,13 +292,4 @@
border-radius: var(--radius-sm);
padding: var(--spacing-sm);
}

.icon-buttons {
display: flex;
position: absolute;
top: 6px;
right: 6px;
gap: var(--size-1);
z-index: 1;
}
</style>
22 changes: 9 additions & 13 deletions js/atoms/src/IconButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
export let hasPopup = false;
export let color = "var(--block-label-text-color)";
export let transparent = false;
export let background = "var(--background-fill-primary)";
export let offset = 0;
export let background = "var(--block-background-fill)";
$: _color = highlight ? "var(--color-accent)" : color;
</script>

Expand All @@ -28,15 +27,15 @@
class:transparent
style:color={!disabled && _color ? _color : "var(--block-label-text-color)"}
style:--bg-color={!disabled ? background : "auto"}
style:margin-left={offset + "px"}
>
{#if show_label}<span>{label}</span>{/if}
<div
class:small={size === "small"}
class:large={size === "large"}
class:medium={size === "medium"}
>
<Icon />
<!-- handles icon reactivity -->
<svelte:component this={Icon} />
</div>
</button>

Expand All @@ -47,28 +46,26 @@
align-items: center;
gap: 1px;
z-index: var(--layer-2);
/* background: var(--background-fill-primary); */
border-radius: var(--radius-sm);
border-radius: var(--radius-xs);
color: var(--block-label-text-color);
border: 1px solid transparent;
}

button:hover {
background-color: var(--background-fill-secondary);
}

button[disabled] {
opacity: 0.5;
box-shadow: none;
}

button[disabled]:hover {
cursor: not-allowed;
/* border: 1px solid var(--button-secondary-border-color); */
/* padding: 2px; */
}

.padded {
padding: 2px;
background: var(--bg-color);
box-shadow: var(--shadow-drop);
border: 1px solid var(--button-secondary-border-color);
}

button:hover,
Expand All @@ -78,8 +75,6 @@
}

.padded:hover {
border: 2px solid var(--button-secondary-border-color-hover);
padding: 1px;
color: var(--block-label-text-color);
}

Expand All @@ -92,6 +87,7 @@
padding: 2px;
display: flex;
align-items: flex-end;
transition: filter 0.2s ease-in-out;
}

.small {
Expand Down
48 changes: 48 additions & 0 deletions js/atoms/src/IconButtonWrapper.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<div class="icon-button-wrapper">
<slot></slot>
</div>

<style>
.icon-button-wrapper {
position: absolute;
display: flex;
flex-direction: row;
top: var(--block-label-margin);
right: var(--block-label-margin);
z-index: var(--layer-2);
gap: var(--spacing-sm);
box-shadow: var(--shadow-drop);
border: 1px solid var(--border-color-primary);
border-top: none;
border-right: none;
border-radius: var(--block-label-right-radius);
background: var(--block-background-fill);
padding: var(--spacing-xxs);
}

.icon-button-wrapper :global(button) {
margin: var(--spacing-xxs);
border-radius: var(--radius-xs);
position: relative;
}

.icon-button-wrapper :global(a.download-link:not(:last-child)),
.icon-button-wrapper :global(button:not(:last-child)) {
margin-right: var(--spacing-xxs);
}

.icon-button-wrapper :global(a.download-link:not(:last-child)::after),
.icon-button-wrapper :global(button:not(:last-child)::after) {
content: "";
position: absolute;
right: -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>
1 change: 1 addition & 0 deletions js/atoms/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export { default as ShareButton } from "./ShareButton.svelte";
export { default as UploadText } from "./UploadText.svelte";
export { default as Toolbar } from "./Toolbar.svelte";
export { default as SelectSource } from "./SelectSource.svelte";
export { default as IconButtonWrapper } from "./IconButtonWrapper.svelte";

export const BLOCK_KEY = {};
3 changes: 1 addition & 2 deletions js/audio/interactive/InteractiveAudio.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
<StreamingBar {time_limit} />
{#if value === null || streaming}
{#if active_source === "microphone"}
<ModifyUpload {i18n} on:clear={clear} absolute={true} />
<ModifyUpload {i18n} on:clear={clear} />
{#if streaming}
<StreamAudio
{record}
Expand Down Expand Up @@ -290,7 +290,6 @@
on:clear={clear}
on:edit={() => (mode = "edit")}
download={show_download_button ? value.url : null}
absolute={true}
/>

<AudioPlayer
Expand Down
21 changes: 8 additions & 13 deletions js/audio/static/StaticAudio.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<script lang="ts">
import { uploadToHuggingFace } from "@gradio/utils";
import { Empty } from "@gradio/atoms";
import { ShareButton, IconButton, BlockLabel } from "@gradio/atoms";
import {
ShareButton,
IconButton,
BlockLabel,
IconButtonWrapper
} from "@gradio/atoms";
import { Download, Music } from "@gradio/icons";
import type { I18nFormatter } from "@gradio/utils";
import AudioPlayer from "../player/AudioPlayer.svelte";
Expand Down Expand Up @@ -40,7 +45,7 @@
/>

{#if value !== null}
<div class="icon-buttons">
<IconButtonWrapper>
{#if show_download_button}
<DownloadLink
href={value.is_stream
Expand All @@ -64,7 +69,7 @@
{value}
/>
{/if}
</div>
</IconButtonWrapper>

<AudioPlayer
{value}
Expand All @@ -84,13 +89,3 @@
<Music />
</Empty>
{/if}

<style>
.icon-buttons {
display: flex;
position: absolute;
top: 6px;
right: 6px;
gap: var(--size-1);
}
</style>
36 changes: 8 additions & 28 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,13 +306,12 @@
</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);
dispatch("share", {
description: formatted
Expand All @@ -325,15 +324,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 +715,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
26 changes: 4 additions & 22 deletions js/chatbot/shared/CopyAll.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { onDestroy } from "svelte";
import { Copy, Check } from "@gradio/icons";
import type { NormalisedMessage } from "../types";
import { IconButton } from "@gradio/atoms";

let copied = false;
export let value: NormalisedMessage[] | null;
Expand Down Expand Up @@ -45,29 +46,10 @@
});
</script>

<button
<IconButton
Icon={copied ? Check : Copy}
on:click={handle_copy}
title="Copy conversation"
class={copied ? "copied" : "copy-text"}
aria-label={copied ? "Copied conversation" : "Copy conversation"}
>
{#if copied}
<Check />
{:else}
<Copy />
{/if}
</button>

<style>
button {
display: flex;
align-items: center;
width: var(--size-4);
height: var(--size-4);
color: var(--body-text-color-subdued);
}

button:hover {
color: var(--body-text-color);
}
</style>
></IconButton>
2 changes: 1 addition & 1 deletion js/file/shared/FileUpload.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<BlockLabel {show_label} Icon={File} float={!value} label={label || "File"} />

{#if value && (Array.isArray(value) ? value.length > 0 : true)}
<ModifyUpload {i18n} on:clear={handle_clear} absolute />
<ModifyUpload {i18n} on:clear={handle_clear} />
<FilePreview
{i18n}
on:select
Expand Down
Loading
Loading