From b49383106fbf7d018d48ebebba745623051dcf67 Mon Sep 17 00:00:00 2001 From: Jordan Frankfurt Date: Thu, 10 Oct 2024 11:16:46 -0500 Subject: [PATCH] feat: copy frame urls (#1042) * feat: copy frame urls * switch order, switch icon * frame link copied! copy --- .../FrameListItem.tsx | 74 ++++++++++++++----- 1 file changed, 56 insertions(+), 18 deletions(-) diff --git a/apps/web/src/components/Basenames/UsernameProfileSectionFrames/FrameListItem.tsx b/apps/web/src/components/Basenames/UsernameProfileSectionFrames/FrameListItem.tsx index c15dd36934..691903eeb0 100644 --- a/apps/web/src/components/Basenames/UsernameProfileSectionFrames/FrameListItem.tsx +++ b/apps/web/src/components/Basenames/UsernameProfileSectionFrames/FrameListItem.tsx @@ -8,13 +8,32 @@ import { useFrameContext } from 'apps/web/src/components/Basenames/UsernameProfi import Frame from 'apps/web/src/components/Basenames/UsernameProfileSectionFrames/Frame'; import { ActionType } from 'libs/base-ui/utils/logEvent'; import Image, { StaticImageData } from 'next/image'; -import { useCallback } from 'react'; +import { useCallback, useState } from 'react'; import TrashIcon from './assets/trash-icon.svg'; +import { useCopyToClipboard } from 'usehooks-ts'; +import { Icon } from 'apps/web/src/components/Icon/Icon'; export default function FrameListItem({ url }: { url: string }) { const { removeFrame } = useFrameContext(); const { currentWalletIsProfileOwner } = useUsernameProfile(); const { logEventWithContext } = useAnalytics(); + const [isCopied, setIsCopied] = useState(false); + + const [, copy] = useCopyToClipboard(); + const handleCopyFrameURLClick = useCallback(() => { + copy(url) + .then(() => { + setIsCopied(true); + }) + .catch((e) => { + console.error(e); + }) + .finally(() => { + setTimeout(() => { + setIsCopied(false); + }, 2000); + }); + }, [copy, url]); const handleRemoveFrameClick = useCallback(() => { removeFrame(url) @@ -26,23 +45,42 @@ export default function FrameListItem({ url }: { url: string }) { return (
- {currentWalletIsProfileOwner && ( - - + + + + + + - - - + {currentWalletIsProfileOwner && ( - - - - )} + )} + + +
);