Skip to content

Commit 41ad0f7

Browse files
refactor: use Button component instead of plain button in CopyButton (calcom#25489)
* refactor: use Button component instead of plain button in CopyButton Co-Authored-By: eunjae@cal.com <hey@eunjae.dev> * add shrink-0 to StartIcon and EndIcon of Button * remove unused class names --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 0103321 commit 41ad0f7

2 files changed

Lines changed: 15 additions & 22 deletions

File tree

packages/features/insights/hooks/useInsightsColumns.tsx

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { createColumnHelper } from "@tanstack/react-table";
2-
// eslint-disable-next-line no-restricted-imports
32
import startCase from "lodash/startCase";
43
import { useMemo } from "react";
54
import { z } from "zod";
@@ -11,7 +10,7 @@ import { useCopy } from "@calcom/lib/hooks/useCopy";
1110
import { useLocale } from "@calcom/lib/hooks/useLocale";
1211
import { RoutingFormFieldType } from "@calcom/routing-forms/lib/FieldTypes";
1312
import { Badge } from "@calcom/ui/components/badge";
14-
import { Icon } from "@calcom/ui/components/icon";
13+
import { Button } from "@calcom/ui/components/button";
1514

1615
import { BookedByCell } from "../components/BookedByCell";
1716
import { BookingAtCell } from "../components/BookingAtCell";
@@ -349,24 +348,16 @@ function CopyButton({ label, value }: { label: string; value: string }) {
349348
const { copyToClipboard, isCopied } = useCopy();
350349
const { t } = useLocale();
351350
return (
352-
<button
353-
className="flex w-full items-center gap-1 overflow-hidden"
354-
title={value}
351+
<Button
352+
color="minimal"
353+
size="sm"
354+
className="overflow-hidden"
355+
tooltip={value}
356+
EndIcon={isCopied ? "check" : "clipboard"}
355357
onClick={() => {
356358
copyToClipboard(value);
357359
}}>
358-
{!isCopied && (
359-
<>
360-
<span className="truncate">{label}</span>
361-
<Icon name="clipboard" className="shrink-0" size={14} />
362-
</>
363-
)}
364-
{isCopied && (
365-
<>
366-
<span className="grow truncate text-left">{t("copied")}</span>
367-
<Icon name="check" className="shrink-0" size={14} />
368-
</>
369-
)}
370-
</button>
360+
<span className="truncate">{isCopied ? t("copied") : label}</span>
361+
</Button>
371362
);
372363
}

packages/ui/components/button/Button.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,15 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
264264
<>
265265
{variant === "fab" ? (
266266
<>
267-
<Icon name={StartIcon} className="hidden h-4 w-4 stroke-[1.5px] md:inline-flex" />
268-
<Icon name="plus" data-testid="plus" className="inline h-6 w-6 md:hidden" />
267+
<Icon name={StartIcon} className="hidden h-4 w-4 shrink-0 stroke-[1.5px] md:inline-flex" />
268+
<Icon name="plus" data-testid="plus" className="inline h-6 w-6 shrink-0 md:hidden" />
269269
</>
270270
) : (
271271
<Icon
272272
data-name="start-icon"
273273
name={StartIcon}
274274
className={classNames(
275+
"shrink-0",
275276
loading ? "invisible" : "visible",
276277
"button-icon group-[:not(div):active]:translate-y-[0.5px]",
277278
variant === "icon" && "h-4 w-4",
@@ -313,13 +314,14 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
313314
<>
314315
{variant === "fab" ? (
315316
<>
316-
<Icon name={EndIcon} className="-mr-1 me-2 ms-2 hidden h-5 w-5 md:inline" />
317-
<Icon name="plus" data-testid="plus" className="inline h-6 w-6 md:hidden" />
317+
<Icon name={EndIcon} className="-mr-1 me-2 ms-2 hidden h-5 w-5 shrink-0 md:inline" />
318+
<Icon name="plus" data-testid="plus" className="inline h-6 w-6 shrink-0 md:hidden" />
318319
</>
319320
) : (
320321
<Icon
321322
name={EndIcon}
322323
className={classNames(
324+
"shrink-0",
323325
loading ? "invisible" : "visible",
324326
"group-[:not(div):active]:translate-y-[0.5px]",
325327
variant === "icon" && "h-4 w-4",

0 commit comments

Comments
 (0)