From c186d29bc8faee12fd73fb56b4f2d5941890bfbf Mon Sep 17 00:00:00 2001 From: shixuewen Date: Fri, 23 Feb 2024 11:50:18 +0800 Subject: [PATCH] feat: Community links modal UI and routing --- .../src/components/news/links/LinkModal.tsx | 15 ++- .../u3/src/components/news/links/LinkPost.tsx | 15 ++- .../src/components/news/links/LinkPreview.tsx | 18 ++- apps/u3/src/components/social/PostCard.tsx | 8 +- .../src/components/social/farcaster/FCast.tsx | 106 ++++++++++-------- .../components/social/farcaster/FCastTips.tsx | 2 +- .../community/PostsFcMentionedLinks.tsx | 14 ++- 7 files changed, 118 insertions(+), 60 deletions(-) diff --git a/apps/u3/src/components/news/links/LinkModal.tsx b/apps/u3/src/components/news/links/LinkModal.tsx index 08cb0be7..e9ded33e 100644 --- a/apps/u3/src/components/news/links/LinkModal.tsx +++ b/apps/u3/src/components/news/links/LinkModal.tsx @@ -8,10 +8,17 @@ export default function LinkModal({ show, closeModal, data, + isV2Layout, + castClickAction, }: { show: boolean; closeModal: () => void; data: LinkListItem | null; + isV2Layout?: boolean; + castClickAction?: ( + e: React.MouseEvent, + castHex: string + ) => void; }) { return ( @@ -21,7 +28,13 @@ export default function LinkModal({ 'max-sm:w-[100vw] max-sm:p-[0px] max-sm:pt-[30px]' )} > - {data && } + {data && ( + + )} , + castHex: string + ) => void; +}) { const { firstLoading, moreLoading, @@ -70,6 +81,8 @@ export default function LinkPost({ url }: { url: string }) { simpleLayout openFarcasterQR={openFarcasterQR} farcasterUserData={farcasterUserData} + isV2Layout={isV2Layout} + castClickAction={castClickAction} /> ); diff --git a/apps/u3/src/components/news/links/LinkPreview.tsx b/apps/u3/src/components/news/links/LinkPreview.tsx index c45861a6..419b4bdd 100644 --- a/apps/u3/src/components/news/links/LinkPreview.tsx +++ b/apps/u3/src/components/news/links/LinkPreview.tsx @@ -21,8 +21,18 @@ import { cn } from '@/lib/utils'; export type LinkPreviewProps = StyledComponentPropsWithRef<'div'> & { data?: LinkListItem; + isV2Layout?: boolean; + castClickAction?: ( + e: React.MouseEvent, + castHex: string + ) => void; }; -export default function LinkPreview({ data, ...otherProps }: LinkPreviewProps) { +export default function LinkPreview({ + data, + isV2Layout, + castClickAction, + ...otherProps +}: LinkPreviewProps) { // const navigate = useNavigate(); const { ref, isFullscreen, onToggle } = useFullScreen(); const [linkParam, setLinkParam] = useState(null); @@ -71,7 +81,11 @@ export default function LinkPreview({ data, ...otherProps }: LinkPreviewProps) { 'max-sm:hidden' )} > - + diff --git a/apps/u3/src/components/social/PostCard.tsx b/apps/u3/src/components/social/PostCard.tsx index ff1b0ab3..8ff73cc1 100644 --- a/apps/u3/src/components/social/PostCard.tsx +++ b/apps/u3/src/components/social/PostCard.tsx @@ -232,7 +232,7 @@ export function PostCardMainWrapper({ return (
-
{data.name}
+
+ {data.name} +
-
+
@{data.handle} · {dayjs(data.createdAt).fromNow()}
diff --git a/apps/u3/src/components/social/farcaster/FCast.tsx b/apps/u3/src/components/social/farcaster/FCast.tsx index 102571c6..8b26bb2a 100644 --- a/apps/u3/src/components/social/farcaster/FCast.tsx +++ b/apps/u3/src/components/social/farcaster/FCast.tsx @@ -223,24 +223,27 @@ export default function FCast({ }} {...wrapperProps} > -
- { - setLinkId(newLinkId); - }} - onLikeSuccess={() => { - changeCastLikesWithCurrFid(true); - }} - onRecastSuccess={() => { - changeCastRecastsWithCurrFid(true); - }} - /> - -
+ {!simpleLayout && ( +
+ { + setLinkId(newLinkId); + }} + onLikeSuccess={() => { + changeCastLikesWithCurrFid(true); + }} + onRecastSuccess={() => { + changeCastRecastsWithCurrFid(true); + }} + /> + +
+ )} +
- { - e.stopPropagation(); - }} - > - { - if (!linkId && linkParam?.url && linkParam?.type) { - getLinkId(linkParam).then((id) => { - if (id) setLinkId(id); - else setLinkId(''); - }); - } - }} - /> - - -
+ {!simpleLayout && ( + <> + { + e.stopPropagation(); + }} + > + { + if (!linkId && linkParam?.url && linkParam?.type) { + getLinkId(linkParam).then((id) => { + if (id) setLinkId(id); + else setLinkId(''); + }); + } + }} + /> + + +
+ + )} +
{ e.stopPropagation(); const replyDirect = diff --git a/apps/u3/src/container/community/PostsFcMentionedLinks.tsx b/apps/u3/src/container/community/PostsFcMentionedLinks.tsx index 2ca9b88c..d6f18a61 100644 --- a/apps/u3/src/container/community/PostsFcMentionedLinks.tsx +++ b/apps/u3/src/container/community/PostsFcMentionedLinks.tsx @@ -1,5 +1,5 @@ import { useEffect, useCallback, useMemo, useState } from 'react'; -import { useOutletContext } from 'react-router-dom'; +import { useNavigate, useOutletContext } from 'react-router-dom'; import useFeedLinks from '@/hooks/news/useFeedLinks'; import useLinksSearchParams from '@/hooks/news/useLinksSearchParams'; import { useFarcasterCtx } from '@/contexts/social/FarcasterCtx'; @@ -7,6 +7,7 @@ import LinkModal from '@/components/news/links/LinkModal'; import CommunityLinks from '@/components/news/links/community/CommunityLinks'; export default function PostsFcMentionedLinks() { + const navigate = useNavigate(); const communityContext = useOutletContext(); // 可以在这个组件根据这个channelId查询,也可以在上层context里查询,数据从communityContext里传递下来 // 可参考MembersLayout 里的 TotalMembers 组件 @@ -45,8 +46,10 @@ export default function PostsFcMentionedLinks() { return (
-
-

Mentioned Links

+
+

+ 🔗 Mentioned Links +

{links && links.length > 0 && ( { + setSelectLink(null); + navigate(`/community/${channelId}/posts/fc/${castHex}`); + }} />