Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(web): add collection copy link button

Richie McIlroy26445115f909
diff --git a/apps/web/app/c/[id]/CollectionCopyLinkButton.tsx b/apps/web/app/c/[id]/CollectionCopyLinkButton.tsx
new file mode 100644
index 000000000..4399b8747
--- /dev/null
+++ b/apps/web/app/c/[id]/CollectionCopyLinkButton.tsx
@@ -0,0 +1,29 @@
+"use client";
+
+import { Button } from "@cap/ui";
+import { faLink } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { toast } from "sonner";
+
+export function CollectionCopyLinkButton() {
+ return (
+ <Button
+ type="button"
+ variant="gray"
+ size="sm"
+ onClick={async () => {
+ try {
+ await navigator.clipboard.writeText(
+ window.location.origin + window.location.pathname,
+ );
+ toast.success("Link copied");
+ } catch {
+ toast.error("Failed to copy link");
+ }
+ }}
+ >
+ <FontAwesomeIcon icon={faLink} className="size-3" />
+ Copy link
+ </Button>
+ );
+}