Skip to content

Commit e40df25

Browse files
abidlabsclaudegradio-pr-bot
authored
Consolidate copy button implementations to use IconButton (#11832)
* Consolidate copy button implementations to use IconButton Replace custom copy button styling in Textbox and Dialogue components with standardized IconButton from atoms. This fixes dark mode visibility issues in citrus theme and reduces code duplication by removing 38 lines of duplicate CSS. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * add changeset * add changeset --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
1 parent c172398 commit e40df25

File tree

3 files changed

+21
-72
lines changed

3 files changed

+21
-72
lines changed

.changeset/old-parrots-fold.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@gradio/dialogue": patch
3+
"@gradio/textbox": patch
4+
"gradio": patch
5+
---
6+
7+
feat:Consolidate copy button implementations to use IconButton

js/dialogue/Dialogue.svelte

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { createEventDispatcher, tick, onMount } from "svelte";
3-
import { BlockTitle } from "@gradio/atoms";
3+
import { BlockTitle, IconButton, IconButtonWrapper } from "@gradio/atoms";
44
import { Copy, Check, Send, Plus, Trash } from "@gradio/icons";
55
import { fade } from "svelte/transition";
66
import { BaseDropdown, BaseDropdownOptions } from "@gradio/dropdown";
@@ -454,21 +454,13 @@
454454

455455
<label class:container>
456456
{#if show_label && show_copy_button}
457-
{#if copied}
458-
<button
459-
in:fade={{ duration: 300 }}
460-
class="copy-button"
461-
aria-label="Copied"
462-
aria-roledescription="Text copied"><Check /></button
463-
>
464-
{:else}
465-
<button
457+
<IconButtonWrapper>
458+
<IconButton
459+
Icon={copied ? Check : Copy}
466460
on:click={handle_copy}
467-
class="copy-button"
468-
aria-label="Copy"
469-
aria-roledescription="Copy text"><Copy /></button
470-
>
471-
{/if}
461+
label={copied ? "Copied" : "Copy"}
462+
/>
463+
</IconButtonWrapper>
472464
{/if}
473465

474466
<BlockTitle {show_label} {info}>{label}</BlockTitle>
@@ -933,27 +925,6 @@
933925
width: 22px;
934926
}
935927
936-
.copy-button {
937-
display: flex;
938-
position: absolute;
939-
top: var(--block-label-margin);
940-
right: var(--block-label-margin);
941-
align-items: center;
942-
box-shadow: var(--shadow-drop);
943-
border: 1px solid var(--border-color-primary);
944-
border-top: none;
945-
border-right: none;
946-
border-radius: var(--block-label-right-radius);
947-
background: var(--block-label-background-fill);
948-
padding: 5px;
949-
width: 22px;
950-
height: 22px;
951-
overflow: hidden;
952-
color: var(--block-label-color);
953-
font: var(--font-sans);
954-
font-size: var(--button-small-text-size);
955-
}
956-
957928
.tag-menu {
958929
position: absolute;
959930
width: 100%;

js/textbox/shared/Textbox.svelte

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
createEventDispatcher,
66
tick
77
} from "svelte";
8-
import { BlockTitle } from "@gradio/atoms";
8+
import { BlockTitle, IconButton, IconButtonWrapper } from "@gradio/atoms";
99
import { Copy, Check, Send, Square } from "@gradio/icons";
1010
import { fade } from "svelte/transition";
1111
import type { SelectData, CopyData } from "@gradio/utils";
@@ -238,21 +238,13 @@
238238
<!-- svelte-ignore a11y-autofocus -->
239239
<label class:container class:show_textbox_border>
240240
{#if show_label && show_copy_button}
241-
{#if copied}
242-
<button
243-
in:fade={{ duration: 300 }}
244-
class="copy-button"
245-
aria-label="Copied"
246-
aria-roledescription="Text copied"><Check /></button
247-
>
248-
{:else}
249-
<button
241+
<IconButtonWrapper>
242+
<IconButton
243+
Icon={copied ? Check : Copy}
250244
on:click={handle_copy}
251-
class="copy-button"
252-
aria-label="Copy"
253-
aria-roledescription="Copy text"><Copy /></button
254-
>
255-
{/if}
245+
label={copied ? "Copied" : "Copy"}
246+
/>
247+
</IconButtonWrapper>
256248
{/if}
257249
<BlockTitle {show_label} {info}>{label}</BlockTitle>
258250

@@ -449,27 +441,6 @@
449441
color: var(--input-placeholder-color);
450442
}
451443
452-
.copy-button {
453-
display: flex;
454-
position: absolute;
455-
top: var(--block-label-margin);
456-
right: var(--block-label-margin);
457-
align-items: center;
458-
box-shadow: var(--shadow-drop);
459-
border: 1px solid var(--border-color-primary);
460-
border-top: none;
461-
border-right: none;
462-
border-radius: var(--block-label-right-radius);
463-
background: var(--block-label-background-fill);
464-
padding: 5px;
465-
width: 22px;
466-
height: 22px;
467-
overflow: hidden;
468-
color: var(--block-label-color);
469-
font: var(--font-sans);
470-
font-size: var(--button-small-text-size);
471-
}
472-
473444
/* Same submit button style as MultimodalTextbox for the consistent UI */
474445
.input-container {
475446
display: flex;

0 commit comments

Comments
 (0)