diff --git a/packages/ord-connect/src/components/OrdConnectKit.tsx b/packages/ord-connect/src/components/OrdConnectKit.tsx index 6dc571bd..c69a2c42 100644 --- a/packages/ord-connect/src/components/OrdConnectKit.tsx +++ b/packages/ord-connect/src/components/OrdConnectKit.tsx @@ -1,3 +1,5 @@ +import { ReactNode } from "react"; + import { useOrdConnect } from "../providers/OrdConnectProvider"; import { PostConnectButton } from "./PostConnectButton"; @@ -10,6 +12,7 @@ export interface OrdConnectKitProp { customStyle?: string; onViewProfile?: () => void; disableMobile?: boolean; + renderAvatar?: (address: string, size: "large" | "small") => ReactNode; } /** @@ -25,6 +28,7 @@ export function OrdConnectKit({ customStyle, onViewProfile, disableMobile, + renderAvatar, }: OrdConnectKitProp) { const { address, network, isModalOpen, openModal, closeModal } = useOrdConnect(); @@ -37,6 +41,7 @@ export function OrdConnectKit({ network={network} onViewProfile={onViewProfile} onChangeWallet={openModal} + renderAvatar={renderAvatar} /> ) : ( @@ -46,6 +51,7 @@ export function OrdConnectKit({ isOpen={isModalOpen} closeModal={closeModal} disableMobile={disableMobile} + renderAvatar={renderAvatar} /> ); diff --git a/packages/ord-connect/src/components/PostConnectButton/index.tsx b/packages/ord-connect/src/components/PostConnectButton/index.tsx index bf6d3f9b..2eddb10b 100644 --- a/packages/ord-connect/src/components/PostConnectButton/index.tsx +++ b/packages/ord-connect/src/components/PostConnectButton/index.tsx @@ -1,4 +1,4 @@ -import { Fragment } from "react"; +import { Fragment, ReactNode } from "react"; import Avatar from "boring-avatars"; import { Menu, Transition } from "@headlessui/react"; @@ -14,6 +14,7 @@ interface PostConnectButtonProp { network: string; onViewProfile?: () => void; onChangeWallet?: () => void; + renderAvatar?: (address: string, size: "large" | "small") => ReactNode; } export function PostConnectButton({ @@ -21,6 +22,7 @@ export function PostConnectButton({ network, onViewProfile, onChangeWallet, + renderAvatar, }: PostConnectButtonProp) { const { disconnectWallet, wallet } = useOrdConnect(); @@ -33,12 +35,16 @@ export function PostConnectButton({ <>
- + {renderAvatar ? ( + renderAvatar(address, "large") + ) : ( + + )} void; isDisabled?: boolean; isMobileDevice?: boolean; + renderAvatar?: (address: string, size: "large" | "small") => ReactNode; } export function WalletButton({ @@ -29,6 +30,7 @@ export function WalletButton({ setErrorMessage, isDisabled, isMobileDevice, + renderAvatar, }: WalletButtonProp) { const { wallet: _connectedWallet, address: _connectedAddress } = useOrdConnect(); @@ -82,12 +84,16 @@ export function WalletButton({
{connectedWallet === wallet && connectedAddress.ordinals ? (
- + {renderAvatar ? ( + renderAvatar(connectedAddress.ordinals, "small") + ) : ( + + )} {truncateMiddle(connectedAddress.ordinals)} diff --git a/packages/ord-connect/src/components/SelectWalletModal/index.tsx b/packages/ord-connect/src/components/SelectWalletModal/index.tsx index aa569715..430349a2 100644 --- a/packages/ord-connect/src/components/SelectWalletModal/index.tsx +++ b/packages/ord-connect/src/components/SelectWalletModal/index.tsx @@ -1,4 +1,4 @@ -import { Fragment, useCallback, useEffect, useState } from "react"; +import { Fragment, ReactNode, useCallback, useEffect, useState } from "react"; import { Dialog, Transition } from "@headlessui/react"; import { BrowserWalletNotInstalledError, @@ -20,6 +20,7 @@ interface SelectWalletModalProp { isOpen: boolean; closeModal: () => void; disableMobile?: boolean; + renderAvatar?: (address: string, size: "large" | "small") => ReactNode; } const WALLET_CHROME_EXTENSION_URL: Record = { @@ -31,6 +32,7 @@ export function SelectWalletModal({ isOpen, closeModal, disableMobile, + renderAvatar, }: SelectWalletModalProp) { const { updateAddress, @@ -269,6 +271,7 @@ export function SelectWalletModal({ setErrorMessage={setErrorMessage} isDisabled={isMobile} // disable unisat on mobile until it is supported isMobileDevice={isMobile} + renderAvatar={renderAvatar} />
@@ -280,6 +283,7 @@ export function SelectWalletModal({ icon={XverseWalletIcon} setErrorMessage={setErrorMessage} isMobileDevice={isMobile} + renderAvatar={renderAvatar} /> ) : (