diff --git a/src/components/DelegateCard.tsx b/src/components/DelegateCard.tsx index c58d05b..d9aceb8 100644 --- a/src/components/DelegateCard.tsx +++ b/src/components/DelegateCard.tsx @@ -6,14 +6,15 @@ import { ContentReveal } from './ui/content-reveal' import { cn } from '@/lib/utils' import { sanitizeString } from '@/lib/utils' import { useNetwork } from '@/contexts/NetworkContext' -import { toast } from 'sonner' import { LinkIcon } from 'lucide-react' import Markdown from 'react-markdown' import { H, H2, H3, Hr, P } from './ui/md' import { AnchorLink } from './ui/anchorLink' -import { useCallback, useMemo } from 'react' -import { IdentityInfo } from './IdentityInfo' +import { useCallback, useMemo, useState } from 'react' +import { IdentityIcon } from './IdentityIcon' +import { PopoverContent, PopoverTrigger } from './ui/popover' +import { Popover } from '@radix-ui/react-popover' interface Props { delegate: Delegate @@ -31,8 +32,10 @@ export const DelegateCard = ({ const { network } = useNetwork() const navigate = useNavigate() const { search } = useLocation() + const [isCopyPopoverOpen, setIsCopyPopoverOpen] = useState(false) const copyLink = useMemo( - () => `${window.location.host}/${network}/${sanitizeString(name)}`, + () => + `${location.protocol}//${location.host}/${network}/${sanitizeString(name)}`, [name, network], ) const shouldHideLongDescription = @@ -44,9 +47,10 @@ export const DelegateCard = ({ const onCopy = useCallback(() => { navigator.clipboard.writeText(copyLink) - toast.success('Copied to clipboard', { - duration: 1000, - }) + setIsCopyPopoverOpen(true) + setTimeout(() => { + setIsCopyPopoverOpen(false) + }, 1000) }, [copyLink]) const DelegateAvatar: React.FC = () => { @@ -70,12 +74,20 @@ export const DelegateCard = ({
- {hasShareButton && ( - + + event.stopPropagation()}> + + + + Direct link copied! + + )} + + {name}
diff --git a/src/components/IdentityIcon.tsx b/src/components/IdentityIcon.tsx new file mode 100644 index 0000000..ee3dbab --- /dev/null +++ b/src/components/IdentityIcon.tsx @@ -0,0 +1,75 @@ +import { IoCheckmarkCircle, IoMail } from 'react-icons/io5' +import { useIdentity } from '@/hooks/useIdentity' +import { TbCircleDashedMinus, TbWorld } from 'react-icons/tb' +import { Popover, PopoverContent, PopoverTrigger } from './ui/popover' +import { AnchorLink } from './ui/anchorLink' +import { BsTwitterX } from 'react-icons/bs' +import { MessageCircleDashed, User } from 'lucide-react' + +interface Props { + address: string +} + +export const IdentityIcon = ({ address }: Props) => { + const identity = useIdentity(address) + + if (!identity?.display) return null + + return ( +
+ + + {identity?.judgement ? ( + + ) : ( + + )} + + + {identity.display && ( +

{identity.display}

+ )} + {identity.legal && ( +
+ + {identity.legal} +
+ )} + {identity.twitter && ( +
+ + + {identity.twitter} + +
+ )} + {identity.email && ( +
+ + + {identity.email} + +
+ )} + {identity.web && ( +
+ + + {identity.web} + +
+ )} + {identity.matrix && ( +
+ + {identity.matrix} +
+ )} +
+
+
+ ) +} diff --git a/src/components/IdentityInfo.tsx b/src/components/IdentityInfo.tsx deleted file mode 100644 index c95f7ce..0000000 --- a/src/components/IdentityInfo.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { BsTwitterX } from 'react-icons/bs' -import { IoCheckmarkCircle, IoMail } from 'react-icons/io5' -import { TbWorld } from 'react-icons/tb' -import { Button } from './ui/button' -import { useIdentity } from '@/hooks/useIdentity' -import { TbCircleDashedMinus } from 'react-icons/tb' - -interface Props { - name: string - address: string -} - -export const IdentityInfo = ({ name, address }: Props) => { - const identity = useIdentity(address) - - return ( - <> - {identity?.display ? ( -
- {identity?.display} - {identity?.judgement ? ( - - ) : ( - - )} -
- ) : ( - name - )} - {identity && ( -
- {identity?.web && ( - - )} - {identity?.twitter && ( - - )} - {identity?.email && ( - - )} -
- )} - - ) -}