@@ -44,61 +44,68 @@ export function CopyButton({
4444
4545 const { icon : iconSize , button : buttonSize } = sizes [ size ] ;
4646
47- const button =
48- variant === "icon" ? (
49- < button
50- type = "button"
51- aria-label = { copied ? "Copied" : "Copy" }
52- onClick = { copy }
53- className = { cn (
54- buttonSize ,
55- "flex items-center justify-center rounded border border-border-bright bg-background-hover" ,
56- copied
57- ? "text-green-500"
58- : "text-text-dimmed hover:border-border-bright hover:bg-background-raised hover:text-text-bright" ,
59- buttonClassName
60- ) }
61- >
62- { copied ? (
63- < ClipboardCheckIcon className = { iconSize } />
64- ) : (
65- < ClipboardIcon className = { iconSize } />
66- ) }
67- </ button >
68- ) : (
69- < Button
70- variant = { `${ buttonVariant } /${ size === "extra-small" ? "small" : size } ` }
71- onClick = { copy }
72- className = { cn ( "shrink-0" , buttonClassName ) }
73- LeadingIcon = {
74- copied ? (
75- < ClipboardCheckIcon
76- className = { cn (
77- iconSize ,
78- buttonVariant === "primary" ? "text-background-dimmed" : "text-green-500"
79- ) }
80- />
81- ) : (
82- < ClipboardIcon
83- className = { cn (
84- iconSize ,
85- buttonVariant === "primary" ? "text-background-dimmed" : "text-text-dimmed"
86- ) }
87- />
88- )
89- }
90- >
91- { children }
92- </ Button >
47+ if ( variant === "button" ) {
48+ return (
49+ < span className = { className } >
50+ < Button
51+ variant = { `${ buttonVariant } /${ size === "extra-small" ? "small" : size } ` }
52+ onClick = { copy }
53+ className = { cn ( "shrink-0" , buttonClassName ) }
54+ tooltip = { showTooltip ? ( copied ? "Copied!" : "Copy" ) : undefined }
55+ LeadingIcon = {
56+ copied ? (
57+ < ClipboardCheckIcon
58+ className = { cn (
59+ iconSize ,
60+ buttonVariant === "primary" ? "text-background-dimmed" : "text-green-500"
61+ ) }
62+ />
63+ ) : (
64+ < ClipboardIcon
65+ className = { cn (
66+ iconSize ,
67+ buttonVariant === "primary" ? "text-background-dimmed" : "text-text-dimmed"
68+ ) }
69+ />
70+ )
71+ }
72+ >
73+ { children }
74+ </ Button >
75+ </ span >
9376 ) ;
77+ }
9478
95- if ( ! showTooltip ) return < span className = { className } > { button } </ span > ;
79+ const iconButton = (
80+ < button
81+ type = "button"
82+ aria-label = { copied ? "Copied" : "Copy" }
83+ onClick = { copy }
84+ className = { cn (
85+ buttonSize ,
86+ "flex items-center justify-center rounded border border-border-bright bg-background-hover" ,
87+ copied
88+ ? "text-green-500"
89+ : "text-text-dimmed hover:border-border-bright hover:bg-background-raised hover:text-text-bright" ,
90+ buttonClassName
91+ ) }
92+ >
93+ { copied ? (
94+ < ClipboardCheckIcon className = { iconSize } />
95+ ) : (
96+ < ClipboardIcon className = { iconSize } />
97+ ) }
98+ </ button >
99+ ) ;
100+
101+ if ( ! showTooltip ) return < span className = { className } > { iconButton } </ span > ;
96102
97103 return (
98104 < span className = { className } >
99105 < SimpleTooltip
100106 asChild
101- button = { button }
107+ tabbable
108+ button = { iconButton }
102109 content = { copied ? "Copied!" : "Copy" }
103110 className = "font-sans"
104111 disableHoverableContent
0 commit comments