Skip to content

Commit 3ebe0e1

Browse files
committed
Adds an extra-small size copy button
1 parent cb5bbaf commit 3ebe0e1

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,25 @@ import { useCopy } from "~/hooks/useCopy";
44
import { Button } from "./Buttons";
55
import { SimpleTooltip } from "./Tooltip";
66

7+
const sizes = {
8+
"extra-small": {
9+
icon: "size-3",
10+
button: "h-5 px-1",
11+
},
12+
small: {
13+
icon: "size-3.5",
14+
button: "h-6 px-1",
15+
},
16+
medium: {
17+
icon: "size-4",
18+
button: "h-8 px-1.5",
19+
},
20+
};
21+
722
type CopyButtonProps = {
823
value: string;
924
variant?: "icon" | "button";
10-
size?: "small" | "medium";
25+
size?: keyof typeof sizes;
1126
className?: string;
1227
buttonClassName?: string;
1328
showTooltip?: boolean;
@@ -25,16 +40,15 @@ export function CopyButton({
2540
}: CopyButtonProps) {
2641
const { copy, copied } = useCopy(value);
2742

28-
const iconSize = size === "small" ? "size-3.5" : "size-4";
29-
const buttonSize = size === "small" ? "h-6" : "h-8";
43+
const { icon: iconSize, button: buttonSize } = sizes[size];
3044

3145
const button =
3246
variant === "icon" ? (
3347
<span
3448
onClick={copy}
3549
className={cn(
3650
buttonSize,
37-
"flex items-center justify-center rounded border border-charcoal-650 bg-charcoal-750 px-1.5",
51+
"flex items-center justify-center rounded border border-charcoal-650 bg-charcoal-750",
3852
copied
3953
? "text-green-500"
4054
: "text-text-dimmed hover:border-charcoal-600 hover:bg-charcoal-700 hover:text-text-bright",
@@ -49,7 +63,7 @@ export function CopyButton({
4963
</span>
5064
) : (
5165
<Button
52-
variant={`${buttonVariant}/${size}`}
66+
variant={`${buttonVariant}/${size === "extra-small" ? "small" : size}`}
5367
onClick={copy}
5468
className={cn("shrink-0", buttonClassName)}
5569
>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ function DateTimeTooltipContent({
295295
<Paragraph variant="extra-small" className="text-text-dimmed">
296296
{dateTime}
297297
</Paragraph>
298-
<CopyButton value={isoDateTime} variant="icon" size="small" showTooltip={false} />
298+
<CopyButton value={isoDateTime} variant="icon" size="extra-small" showTooltip={false} />
299299
</div>
300300
</div>
301301
);

0 commit comments

Comments
 (0)