Hey is a decentralized and permissionless social media app built with Lens Protocol 馃尶
at main 38 lines 1.0 kB view raw
1import { MenuItem } from "@headlessui/react"; 2import { LinkIcon } from "@heroicons/react/24/outline"; 3import getAccount from "@hey/helpers/getAccount"; 4import type { AccountFragment } from "@hey/indexer"; 5import cn from "@/helpers/cn"; 6import stopEventPropagation from "@/helpers/stopEventPropagation"; 7import useCopyToClipboard from "@/hooks/useCopyToClipboard"; 8 9interface CopyLinkProps { 10 account: AccountFragment; 11} 12 13const CopyLink = ({ account }: CopyLinkProps) => { 14 const copyLink = useCopyToClipboard( 15 `${location.origin}${getAccount(account).link}`, 16 "Link copied to clipboard!" 17 ); 18 return ( 19 <MenuItem 20 as="div" 21 className={({ focus }) => 22 cn( 23 { "dropdown-active": focus }, 24 "m-2 flex cursor-pointer items-center space-x-2 rounded-lg px-2 py-1.5 text-sm" 25 ) 26 } 27 onClick={(event) => { 28 stopEventPropagation(event); 29 copyLink(); 30 }} 31 > 32 <LinkIcon className="size-4" /> 33 <div>Copy link</div> 34 </MenuItem> 35 ); 36}; 37 38export default CopyLink;