From 808ee6a54a2fa0fc1909cf3365d2e38b5252343d Mon Sep 17 00:00:00 2001 From: Suemor Date: Thu, 20 Apr 2023 17:58:56 +0800 Subject: [PATCH] feat: follow button in the list (#388) --- src/components/common/CharacterList.tsx | 50 +++-------------- src/components/common/CharacterListItem.tsx | 60 +++++++++++++++++++++ src/components/ui/Modal.tsx | 6 ++- 3 files changed, 71 insertions(+), 45 deletions(-) create mode 100644 src/components/common/CharacterListItem.tsx diff --git a/src/components/common/CharacterList.tsx b/src/components/common/CharacterList.tsx index d1f9fc4b..48d16c3a 100644 --- a/src/components/common/CharacterList.tsx +++ b/src/components/common/CharacterList.tsx @@ -1,15 +1,11 @@ import { useTranslation } from "next-i18next" +import React from "react" import InfiniteScroll from "react-infinite-scroller" -import { CharacterFloatCard } from "~/components/common/CharacterFloatCard" -import { BlockchainIcon } from "~/components/icons/BlockchainIcon" import { Modal } from "~/components/ui/Modal" -import { CSB_SCAN } from "~/lib/env" -import { getSiteLink } from "~/lib/helpers" -import { Avatar } from "../ui/Avatar" import { Button } from "../ui/Button" -import { UniLink } from "../ui/UniLink" +import CharacterListItem from "./CharacterListItem" export const CharacterList: React.FC<{ open: boolean @@ -24,7 +20,7 @@ export const CharacterList: React.FC<{ const { t } = useTranslation("common") return ( - +
{ const character = sub?.character || sub?.fromCharacter return ( -
- - - - - {character?.metadata?.content?.name} - - @{character?.handle} - - - - - -
+ sub={sub} + character={character} + /> ) }), ) diff --git a/src/components/common/CharacterListItem.tsx b/src/components/common/CharacterListItem.tsx new file mode 100644 index 00000000..b2dab84d --- /dev/null +++ b/src/components/common/CharacterListItem.tsx @@ -0,0 +1,60 @@ +import React, { memo } from "react" + +import { CharacterFloatCard } from "~/components/common/CharacterFloatCard" +import { BlockchainIcon } from "~/components/icons/BlockchainIcon" +import { CSB_SCAN } from "~/lib/env" +import { getSiteLink } from "~/lib/helpers" + +import { Avatar } from "../ui/Avatar" +import { UniLink } from "../ui/UniLink" +import { FollowingButton } from "./FollowingButton" + +const CharacterListItem: React.FC<{ + character: any + sub: any +}> = ({ character, sub }) => { + return ( +
+
+ + + + + {character?.metadata?.content?.name} + @{character?.handle} + + + + +
+ +
+ ) +} + +export default memo(CharacterListItem) diff --git a/src/components/ui/Modal.tsx b/src/components/ui/Modal.tsx index bb7a25b9..6c11cee4 100644 --- a/src/components/ui/Modal.tsx +++ b/src/components/ui/Modal.tsx @@ -1,3 +1,4 @@ +import clsx from "clsx" import React from "react" import { Dialog } from "@headlessui/react" @@ -11,12 +12,13 @@ export const Modal: React.FC<{ title?: string | React.ReactNode titleIcon?: React.ReactNode size?: "md" | "lg" | "sm" -}> = ({ open, setOpen, children, title, titleIcon, size = "md" }) => { + zIndex?: number +}> = ({ open, setOpen, children, title, titleIcon, size = "md", zIndex }) => { return ( setOpen(false)} - className="relative z-50" + className={clsx("relative", zIndex ? `z-${zIndex}` : "z-50")} > {/* The backdrop, rendered as a fixed sibling to the panel container */}