Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,15 @@ import { Flex } from '../flex';
import * as cx from './profile-dropdown-trigger.css';
import { WalletCard } from './profile-dropdown-wallet-card.component';

import type { ProfileType } from './profile-dropdown-wallet-card.component';
import type { WalletType } from './profile-dropdown.data';

export type Props = Omit<ComponentPropsWithoutRef<'button'>, 'type'> & {
disabled?: boolean;
active?: boolean;
title: string;
subtitle?: string;
profile?: {
imageSrc: string;
fallbackText: string;
alt?: string;
delayMs?: number;
};
profile?: ProfileType;
type: WalletType;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { Flex } from '../flex';
import { Grid, Cell } from '../grid';

import { Trigger } from './profile-dropdown-trigger.component';

import type { ProfileType } from './profile-dropdown-wallet-card.component';
const subtitle = `Reusable button component for use in a variety of controls containing only an icon for its content.`;

export default {
Expand All @@ -24,11 +26,13 @@ const TriggerSample = ({
id,
active,
hasSubtitle = true,
profile,
}: Readonly<{
disabled?: boolean;
id?: string;
active?: boolean;
hasSubtitle?: boolean;
profile?: ProfileType;
}>): JSX.Element => (
<Trigger
title="Alice's wallet"
Expand All @@ -37,6 +41,7 @@ const TriggerSample = ({
id={id}
active={active}
type="hot"
profile={profile}
/>
);

Expand Down Expand Up @@ -67,6 +72,21 @@ export const Overview = (): JSX.Element => (
<Flex gap="$16" alignItems="center" w="$fill" justifyContent="center">
<TriggerSample />
<TriggerSample hasSubtitle={false} />
<TriggerSample
hasSubtitle={false}
profile={{
customProfileComponent: (
<Flex
alignItems="center"
w={'$32'}
h={'$32'}
justifyContent="center"
>
TT
</Flex>
),
}}
/>
</Flex>
</Section>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,26 @@ import { WalletIcon } from './profile-dropdown-wallet-icon.component';

import type { WalletType } from './profile-dropdown.data';

type UserProfileComponentType = {
imageSrc: string;
fallbackText: string;
alt?: string;
delayMs?: number;
};

type CustomProfileComponentType = {
customProfileComponent: React.ReactNode;
};

export type ProfileType = UserProfileComponentType | CustomProfileComponentType;

export interface Props {
title: {
text: string;
type: 'button' | 'content';
};
subtitle?: string;
profile?: {
imageSrc: string;
fallbackText: string;
alt?: string;
delayMs?: number;
};
profile?: ProfileType;
type: WalletType;
testId?: string;
}
Expand All @@ -32,6 +40,22 @@ const makeTestId = (namespace = '', path = ''): string => {
return namespace === '' ? namespace : `${namespace}${path}`;
};

const getProfileImage = (
profile: ProfileType,
testId: string,
): React.ReactNode => {
if ('customProfileComponent' in profile) {
return profile.customProfileComponent;
}
return (
<UserProfile
{...profile}
radius="rounded"
testId={makeTestId(testId, '-icon')}
/>
);
};

export const WalletCard = ({
title,
subtitle,
Expand All @@ -43,16 +67,11 @@ export const WalletCard = ({

return (
<Flex>
{profile === undefined ? (
<WalletIcon type={type} testId={makeTestId(testId, '-icon')} />
{profile ? (
getProfileImage(profile, testId)
) : (
<UserProfile
{...profile}
radius="rounded"
testId={makeTestId(testId, '-icon')}
/>
<WalletIcon type={type} testId={makeTestId(testId, '-icon')} />
)}

{subtitle ? (
<Flex flexDirection="column" ml="$10" h="$32" alignItems="flex-start">
<Title color="secondary" data-testid={makeTestId(testId, '-title')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ import { Flex } from '../flex';
import { WalletCard } from './profile-dropdown-wallet-card.component';
import * as cx from './profile-dropdown-wallet-option.css';

import type { ProfileType } from './profile-dropdown-wallet-card.component';
import type { WalletType } from './profile-dropdown.data';

export type Props = Omit<ComponentPropsWithoutRef<'button'>, 'type'> & {
disabled?: boolean;
title: string;
subtitle?: string;
profile?: {
imageSrc: string;
fallbackText: string;
alt?: string;
delayMs?: number;
};
profile?: ProfileType;
type: WalletType;
onOpenAccountsMenu?: () => void;
};
Expand Down