-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wallet social profiles in dashboard (#4502)
before: <img width="1942" alt="image" src="https://github.com/user-attachments/assets/8ac59faa-f81c-4670-98e5-f750ce68e5d6"> after: <img width="1819" alt="image" src="https://github.com/user-attachments/assets/c8c015eb-528b-44a7-8cd5-478ca3ca907e"> <!-- start pr-codex --> --- ## PR-Codex overview This PR adds social API domain support, new UI components, and updates dependencies. ### Detailed summary - Added `THIRDWEB_SOCIAL_API_DOMAIN` in `urls.ts` - Added `WalletAddress` component - Updated UI components in various files - Added new dependencies like `@radix-ui/react-avatar` and `@radix-ui/react-hover-card` > The following files were skipped due to too many changes: `apps/dashboard/src/components/wallets/ConnectWalletMiniPlayground/MiniPlayground.tsx`, `apps/dashboard/src/contract-ui/tabs/analytics/page.tsx`, `apps/dashboard/src/components/contract-components/contract-deploy-form/split-fieldset.tsx`, `apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx`, `apps/dashboard/src/contract-ui/tabs/manage/components/InstalledModulesTable.tsx`, `apps/dashboard/src/components/contract-components/contract-table-v2/index.tsx`, `apps/dashboard/src/components/pay/PayAnalytics/components/PaymentHistory.tsx`, `apps/dashboard/src/contract-ui/tabs/overview/components/MarketplaceDetails.tsx`, `apps/dashboard/src/contract-ui/tabs/nfts/components/table.tsx`, `apps/dashboard/src/pages/[chain_id]/[...paths].tsx`, `apps/dashboard/src/components/embedded-wallets/Users/index.tsx`, `apps/dashboard/src/components/engine/overview/engine-overview.tsx`, `apps/dashboard/src/components/engine/permissions/access-tokens-table.tsx`, `apps/dashboard/src/contract-ui/tabs/shared-components/marketplace-table.tsx`, `apps/dashboard/src/pages/dashboard/connect/analytics.tsx`, `apps/dashboard/src/app/(dashboard)/styleguide/page.tsx`, `apps/dashboard/src/contract-ui/tabs/account-permissions/components/account-signer.tsx`, `apps/dashboard/src/components/engine/engine-instances-table.tsx`, `apps/dashboard/src/components/engine/overview/backend-wallets-table.tsx`, `apps/dashboard/src/components/engine/overview/transactions-table.tsx`, `apps/dashboard/src/components/pay/PayAnalytics/components/PayCustomersTable.tsx`, `apps/dashboard/src/@/components/ui/hover-card.tsx`, `apps/dashboard/src/@/components/ui/avatar.tsx`, `apps/dashboard/src/@/components/blocks/wallet-address.tsx`, `pnpm-lock.yaml` > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
- Loading branch information
Showing
52 changed files
with
994 additions
and
723 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
190 changes: 190 additions & 0 deletions
190
apps/dashboard/src/@/components/blocks/wallet-address.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
"use client"; | ||
|
||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; | ||
import { | ||
HoverCard, | ||
HoverCardContent, | ||
HoverCardTrigger, | ||
} from "@/components/ui/hover-card"; | ||
import { Check, Copy, ExternalLinkIcon } from "lucide-react"; | ||
import { useMemo, useState } from "react"; | ||
import { | ||
Blobbie, | ||
MediaRenderer, | ||
type SocialProfile, | ||
useSocialProfiles, | ||
} from "thirdweb/react"; | ||
import { resolveScheme } from "thirdweb/storage"; | ||
import { thirdwebClient } from "../../constants/client"; | ||
import { cn } from "../../lib/utils"; | ||
import { Badge } from "../ui/badge"; | ||
import { Button } from "../ui/button"; | ||
|
||
export function WalletAddress(props: { | ||
address: string; | ||
shortenAddress?: boolean; | ||
className?: string; | ||
}) { | ||
const [shortenedAddress, lessShortenedAddress] = useMemo(() => { | ||
return [ | ||
props.shortenAddress !== false | ||
? `${props.address.slice(0, 6)}...${props.address.slice(-4)}` | ||
: props.address, | ||
`${props.address.slice(0, 14)}...${props.address.slice(-12)}`, | ||
]; | ||
}, [props.address, props.shortenAddress]); | ||
|
||
const profiles = useSocialProfiles({ | ||
address: props.address, | ||
client: thirdwebClient, | ||
}); | ||
|
||
const [isCopied, setIsCopied] = useState(false); | ||
|
||
const copyToClipboard = async () => { | ||
try { | ||
await navigator.clipboard.writeText(props.address); | ||
setIsCopied(true); | ||
setTimeout(() => setIsCopied(false), 2000); // Reset after 2 seconds | ||
} catch (err) { | ||
console.error("Failed to copy: ", err); | ||
} | ||
}; | ||
|
||
return ( | ||
<HoverCard> | ||
<HoverCardTrigger asChild> | ||
<Button | ||
onClick={(e) => e.stopPropagation()} | ||
variant="link" | ||
className={cn( | ||
"flex flex-row gap-2 items-center px-0", | ||
props.className, | ||
)} | ||
> | ||
<WalletAvatar | ||
address={props.address} | ||
profiles={profiles.data || []} | ||
/> | ||
<span className="font-mono cursor-pointer"> | ||
{profiles.data?.[0]?.name || shortenedAddress} | ||
</span> | ||
</Button> | ||
</HoverCardTrigger> | ||
<HoverCardContent | ||
className="w-80 border-border" | ||
onClick={(e) => { | ||
// do not close the hover card when clicking anywhere in the content | ||
e.stopPropagation(); | ||
}} | ||
> | ||
<div className="space-y-4"> | ||
<div className="flex items-center justify-between"> | ||
<h3 className="text-lg font-semibold">Wallet Address</h3> | ||
<Button | ||
variant="outline" | ||
size="sm" | ||
onClick={copyToClipboard} | ||
className="flex items-center gap-2" | ||
> | ||
{isCopied ? ( | ||
<Check className="h-4 w-4" /> | ||
) : ( | ||
<Copy className="h-4 w-4" /> | ||
)} | ||
{isCopied ? "Copied!" : "Copy"} | ||
</Button> | ||
</div> | ||
<p className="text-sm font-mono bg-muted p-2 rounded text-center"> | ||
{lessShortenedAddress} | ||
</p> | ||
<h3 className="text-lg font-semibold">Social Profiles</h3> | ||
{profiles.isLoading ? ( | ||
<p className="text-sm text-muted-foreground">Loading profiles...</p> | ||
) : !profiles.data?.length ? ( | ||
<p className="text-sm text-muted-foreground">No profiles found</p> | ||
) : ( | ||
profiles.data?.map((profile) => ( | ||
<div | ||
className="flex flex-row gap-2 items-center" | ||
key={profile.type + profile.name} | ||
> | ||
{profile.avatar && | ||
(profile.avatar.startsWith("http") || | ||
profile.avatar?.startsWith("ipfs")) && ( | ||
<Avatar> | ||
<AvatarImage | ||
src={resolveScheme({ | ||
client: thirdwebClient, | ||
uri: profile.avatar, | ||
})} | ||
alt={profile.name} | ||
/> | ||
{profile.name && ( | ||
<AvatarFallback> | ||
{profile.name.slice(0, 2)} | ||
</AvatarFallback> | ||
)} | ||
</Avatar> | ||
)} | ||
<div className="flex flex-col gap-1 w-full"> | ||
<div className="flex flex-row gap-4 w-full items-center justify-between"> | ||
<h4 className="text-md font-semibold">{profile.name}</h4> | ||
<Badge variant="outline">{profile.type}</Badge> | ||
</div> | ||
{profile.bio && ( | ||
<p className="text-sm text-muted-foreground whitespace-normal line-clamp-1"> | ||
{profile.bio} | ||
</p> | ||
)} | ||
</div> | ||
</div> | ||
)) | ||
)} | ||
<Button | ||
asChild | ||
variant="upsell" | ||
className="text-sm flex flex-row gap-2 items-center" | ||
size="sm" | ||
> | ||
<a | ||
target="_blank" | ||
href="https://blog.thirdweb.com/changelog/introducing-the-social-sdk?ref=dashboard-social-wallet" | ||
rel="noreferrer" | ||
> | ||
Learn more | ||
<ExternalLinkIcon className="size-4" /> | ||
</a> | ||
</Button> | ||
</div> | ||
</HoverCardContent> | ||
</HoverCard> | ||
); | ||
} | ||
|
||
function WalletAvatar(props: { | ||
address: string; | ||
profiles: SocialProfile[]; | ||
}) { | ||
const avatar = useMemo(() => { | ||
return props.profiles.find( | ||
(profile) => | ||
profile.avatar && | ||
(profile.avatar.startsWith("http") || | ||
profile.avatar.startsWith("ipfs")), | ||
)?.avatar; | ||
}, [props.profiles]); | ||
return ( | ||
<div className="size-6 overflow-hidden rounded-full"> | ||
{avatar ? ( | ||
<MediaRenderer | ||
client={thirdwebClient} | ||
src={avatar} | ||
className="size-6" | ||
/> | ||
) : ( | ||
<Blobbie address={props.address} size={24} /> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"use client"; | ||
|
||
import * as AvatarPrimitive from "@radix-ui/react-avatar"; | ||
import * as React from "react"; | ||
|
||
import { cn } from "@/lib/utils"; | ||
|
||
const Avatar = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
Avatar.displayName = AvatarPrimitive.Root.displayName; | ||
|
||
const AvatarImage = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Image>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Image | ||
ref={ref} | ||
className={cn("aspect-square h-full w-full", className)} | ||
{...props} | ||
/> | ||
)); | ||
AvatarImage.displayName = AvatarPrimitive.Image.displayName; | ||
|
||
const AvatarFallback = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Fallback>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Fallback | ||
ref={ref} | ||
className={cn( | ||
"flex h-full w-full items-center justify-center rounded-full bg-muted", | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; | ||
|
||
export { Avatar, AvatarImage, AvatarFallback }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use client"; | ||
|
||
import * as HoverCardPrimitive from "@radix-ui/react-hover-card"; | ||
import * as React from "react"; | ||
|
||
import { cn } from "@/lib/utils"; | ||
|
||
const HoverCard = HoverCardPrimitive.Root; | ||
|
||
const HoverCardTrigger = HoverCardPrimitive.Trigger; | ||
|
||
const HoverCardContent = React.forwardRef< | ||
React.ElementRef<typeof HoverCardPrimitive.Content>, | ||
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content> | ||
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => ( | ||
<HoverCardPrimitive.Content | ||
ref={ref} | ||
align={align} | ||
sideOffset={sideOffset} | ||
className={cn( | ||
"z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName; | ||
|
||
export { HoverCard, HoverCardTrigger, HoverCardContent }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/dashboard/src/app/team/[team_slug]/(team)/~/settings/general/SettingsCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...d/src/app/team/[team_slug]/[project_slug]/connect/account-abstraction/AAFooterSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/pay/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.