Hey is a decentralized and permissionless social media app built with Lens Protocol 馃尶
1import { MenuItem } from "@headlessui/react";
2import { ClipboardDocumentIcon } from "@heroicons/react/24/outline";
3import getPostData from "@hey/helpers/getPostData";
4import type { PostFragment } from "@hey/indexer";
5import cn from "@/helpers/cn";
6import stopEventPropagation from "@/helpers/stopEventPropagation";
7import useCopyToClipboard from "@/hooks/useCopyToClipboard";
8
9interface CopyPostTextProps {
10 post: PostFragment;
11}
12
13const CopyPostText = ({ post }: CopyPostTextProps) => {
14 const filteredContent = getPostData(post.metadata)?.content || "";
15
16 const copyContent = useCopyToClipboard(
17 filteredContent || "",
18 "Content copied to clipboard!"
19 );
20
21 return (
22 <MenuItem
23 as="div"
24 className={({ focus }) =>
25 cn(
26 { "dropdown-active": focus },
27 "m-2 block cursor-pointer rounded-lg px-2 py-1.5 text-sm"
28 )
29 }
30 onClick={(event) => {
31 stopEventPropagation(event);
32 copyContent();
33 }}
34 >
35 <div className="flex items-center space-x-2">
36 <ClipboardDocumentIcon className="size-4" />
37 <div>{post.commentOn ? "Copy comment text" : "Copy post text"}</div>
38 </div>
39 </MenuItem>
40 );
41};
42
43export default CopyPostText;