Skip to content

Commit 4bac355

Browse files
samejrericallam
authored andcommitted
CopyButton component now takes children
1 parent 4a80331 commit 4bac355

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

apps/webapp/app/components/primitives/CopyButton.tsx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type CopyButtonProps = {
2727
buttonClassName?: string;
2828
showTooltip?: boolean;
2929
buttonVariant?: "primary" | "secondary" | "tertiary" | "minimal";
30+
children?: React.ReactNode;
3031
};
3132

3233
export function CopyButton({
@@ -37,6 +38,7 @@ export function CopyButton({
3738
buttonClassName,
3839
showTooltip = true,
3940
buttonVariant = "tertiary",
41+
children,
4042
}: CopyButtonProps) {
4143
const { copy, copied } = useCopy(value);
4244

@@ -66,22 +68,25 @@ export function CopyButton({
6668
variant={`${buttonVariant}/${size === "extra-small" ? "small" : size}`}
6769
onClick={copy}
6870
className={cn("shrink-0", buttonClassName)}
71+
LeadingIcon={
72+
copied ? (
73+
<ClipboardCheckIcon
74+
className={cn(
75+
iconSize,
76+
buttonVariant === "primary" ? "text-background-dimmed" : "text-green-500"
77+
)}
78+
/>
79+
) : (
80+
<ClipboardIcon
81+
className={cn(
82+
iconSize,
83+
buttonVariant === "primary" ? "text-background-dimmed" : "text-text-dimmed"
84+
)}
85+
/>
86+
)
87+
}
6988
>
70-
{copied ? (
71-
<ClipboardCheckIcon
72-
className={cn(
73-
iconSize,
74-
buttonVariant === "primary" ? "text-background-dimmed" : "text-green-500"
75-
)}
76-
/>
77-
) : (
78-
<ClipboardIcon
79-
className={cn(
80-
iconSize,
81-
buttonVariant === "primary" ? "text-background-dimmed" : "text-text-dimmed"
82-
)}
83-
/>
84-
)}
89+
{children}
8590
</Button>
8691
);
8792

0 commit comments

Comments
 (0)