Skip to content

Commit ae8e5eb

Browse files
feat: allow custom components as profile dropdown profile image
1 parent be50305 commit ae8e5eb

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

src/design-system/profile-dropdown/profile-dropdown-trigger.component.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type Props = Omit<ComponentPropsWithoutRef<'button'>, 'type'> & {
2424
alt?: string;
2525
delayMs?: number;
2626
};
27+
customProfileComponent?: React.ReactNode;
2728
type: WalletType;
2829
};
2930

@@ -42,6 +43,7 @@ export const Trigger = ({
4243
subtitle,
4344
profile,
4445
type,
46+
customProfileComponent,
4547
...props
4648
}: Readonly<Props>): JSX.Element => {
4749
return (
@@ -55,6 +57,7 @@ export const Trigger = ({
5557
<Flex alignItems="center">
5658
<WalletCard
5759
profile={profile}
60+
customProfileComponent={customProfileComponent}
5861
title={{ text: title, type: 'button' }}
5962
subtitle={subtitle}
6063
type={type}

src/design-system/profile-dropdown/profile-dropdown-wallet-card.component.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface Props {
2424
alt?: string;
2525
delayMs?: number;
2626
};
27+
customProfileComponent?: React.ReactNode;
2728
type: WalletType;
2829
testId?: string;
2930
}
@@ -38,21 +39,27 @@ export const WalletCard = ({
3839
profile,
3940
type,
4041
testId = '',
42+
customProfileComponent,
4143
}: Readonly<Props>): JSX.Element => {
4244
const Title = title.type === 'button' ? Text.Label : Text.Address;
4345

46+
const getProfileImage = (): React.ReactNode => {
47+
return customProfileComponent ? (
48+
customProfileComponent
49+
) : profile ? (
50+
<UserProfile
51+
{...profile}
52+
radius="rounded"
53+
testId={makeTestId(testId, '-icon')}
54+
/>
55+
) : (
56+
<WalletIcon type={type} testId={makeTestId(testId, '-icon')} />
57+
);
58+
};
59+
4460
return (
4561
<Flex>
46-
{profile === undefined ? (
47-
<WalletIcon type={type} testId={makeTestId(testId, '-icon')} />
48-
) : (
49-
<UserProfile
50-
{...profile}
51-
radius="rounded"
52-
testId={makeTestId(testId, '-icon')}
53-
/>
54-
)}
55-
62+
{getProfileImage()}
5663
{subtitle ? (
5764
<Flex flexDirection="column" ml="$10" h="$32" alignItems="flex-start">
5865
<Title color="secondary" data-testid={makeTestId(testId, '-title')}>

src/design-system/profile-dropdown/profile-dropdown-wallet-option.component.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type Props = Omit<ComponentPropsWithoutRef<'button'>, 'type'> & {
2424
delayMs?: number;
2525
};
2626
type: WalletType;
27+
customProfileComponent?: React.ReactNode;
2728
onOpenAccountsMenu?: () => void;
2829
};
2930

@@ -36,6 +37,7 @@ export const WalletOption = ({
3637
profile,
3738
type,
3839
onOpenAccountsMenu,
40+
customProfileComponent,
3941
...props
4042
}: Readonly<Props>): JSX.Element => {
4143
return (
@@ -56,6 +58,7 @@ export const WalletOption = ({
5658
subtitle={subtitle}
5759
type={type}
5860
testId="wallet-option"
61+
customProfileComponent={customProfileComponent}
5962
/>
6063
{type !== 'shared' && onOpenAccountsMenu && (
6164
<Box ml="$10">

0 commit comments

Comments
 (0)