Files
cosscom__coss/apps/ui/components/copy-registry.tsx
Pasquale Vitiello 9302c06311 refactor: align biome settings with calcom (#718)
* update biome config + resolve issues

* improve the ui:sync command to run organizeImports on packages

* reformat

* build registry

* exclude base-ui stuff

* fix useExportsLast

* further improvements

* silence errors

* exclude examples app

* update biome + reformat

* format all the other files

* include examples app

* improve copyable-field

* remove unwanted comment

* remove a few unneeded biome comments

* avoid nested ternary

* refactored some shared components

* upgrade base ui to 1.2.0

* fix
2026-03-11 23:09:19 +00:00

56 lines
1.4 KiB
TypeScript

"use client";
import { useCopyToClipboard } from "@coss/ui/hooks/use-copy-to-clipboard";
import { Icons } from "@coss/ui/shared/icons";
import { Tick02Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import type * as React from "react";
import { Button } from "@/registry/default/ui/button";
import {
Tooltip,
TooltipPopup,
TooltipTrigger,
} from "@/registry/default/ui/tooltip";
import { cn } from "@/lib/utils";
export function CopyRegistry({
value,
className,
variant = "ghost",
...props
}: React.ComponentProps<typeof Button> & {
value: string;
src?: string;
}) {
const { isCopied, copyToClipboard } = useCopyToClipboard();
return (
<Tooltip>
<TooltipTrigger
render={
<Button
className={cn(className)}
data-slot="copy-button"
onClick={() => copyToClipboard(value)}
size="icon-sm"
variant={variant}
{...props}
>
<span className="sr-only">Copy</span>
{isCopied ? (
<HugeiconsIcon
className="size-3.5"
icon={Tick02Icon}
strokeWidth={2}
/>
) : (
<Icons.mcp />
)}
</Button>
}
/>
<TooltipPopup>{isCopied ? "Copied" : "Copy Registry URL"}</TooltipPopup>
</Tooltip>
);
}