Skip to content

Commit 6fca8b4

Browse files
Merge pull request #40 from input-output-hk/chore/lw-10712-profile-dropdown-adjustments
chore: make profile dropdown more scalable
2 parents 1f8d71e + be50305 commit 6fca8b4

8 files changed

+66
-21
lines changed

src/design-system/profile-dropdown/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export type { AccountData } from './accounts/profile-dropdown-accounts-list.comp
66
export type { WalletType } from './profile-dropdown.data';
77
export { WalletCard } from './profile-dropdown-wallet-card.component';
88
export { WalletIcon } from './profile-dropdown-wallet-icon.component';
9+
export { Separator } from './profile-dropdown-separator.component';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type Props = Omit<ComponentPropsWithoutRef<'button'>, 'type'> & {
1717
disabled?: boolean;
1818
active?: boolean;
1919
title: string;
20-
subtitle: string;
20+
subtitle?: string;
2121
profile?: {
2222
imageSrc: string;
2323
fallbackText: string;

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ const TriggerSample = ({
2323
disabled,
2424
id,
2525
active,
26+
hasSubtitle = true,
2627
}: Readonly<{
2728
disabled?: boolean;
2829
id?: string;
2930
active?: boolean;
31+
hasSubtitle?: boolean;
3032
}>): JSX.Element => (
3133
<Trigger
3234
title="Alice's wallet"
33-
subtitle="Account #0"
35+
subtitle={hasSubtitle ? 'Account #0' : undefined}
3436
disabled={disabled}
3537
id={id}
3638
active={active}
@@ -62,8 +64,9 @@ export const Overview = (): JSX.Element => (
6264
<Grid columns="$1">
6365
<Cell>
6466
<Section title="Examples">
65-
<Flex flexDirection="column" alignItems="center" w="$fill">
67+
<Flex gap="$16" alignItems="center" w="$fill" justifyContent="center">
6668
<TriggerSample />
69+
<TriggerSample hasSubtitle={false} />
6770
</Flex>
6871
</Section>
6972

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

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface Props {
1717
text: string;
1818
type: 'button' | 'content';
1919
};
20-
subtitle: string;
20+
subtitle?: string;
2121
profile?: {
2222
imageSrc: string;
2323
fallbackText: string;
@@ -52,24 +52,37 @@ export const WalletCard = ({
5252
testId={makeTestId(testId, '-icon')}
5353
/>
5454
)}
55-
<Flex flexDirection="column" ml="$10" h="$32" alignItems="flex-start">
56-
<Title color="secondary" data-testid={makeTestId(testId, '-title')}>
57-
{title.text}
58-
</Title>
59-
<Box
60-
className={cn(cx.subtitleBox, {
61-
[cx.subtitleButtonOffset]: title.type === 'button',
62-
[cx.subtitleContentOffset]: title.type === 'content',
63-
})}
64-
>
55+
56+
{subtitle ? (
57+
<Flex flexDirection="column" ml="$10" h="$32" alignItems="flex-start">
58+
<Title color="secondary" data-testid={makeTestId(testId, '-title')}>
59+
{title.text}
60+
</Title>
61+
<Box
62+
className={cn(cx.subtitleBox, {
63+
[cx.subtitleButtonOffset]: title.type === 'button',
64+
[cx.subtitleContentOffset]: title.type === 'content',
65+
})}
66+
>
67+
<Text.Body.Small
68+
weight="$semibold"
69+
data-testid={makeTestId(testId, '-subtitle')}
70+
>
71+
{subtitle}
72+
</Text.Body.Small>
73+
</Box>
74+
</Flex>
75+
) : (
76+
<Flex ml="$10" h="$32" alignItems="center">
6577
<Text.Body.Small
6678
weight="$semibold"
67-
data-testid={makeTestId(testId, '-subtitle')}
79+
color="secondary"
80+
data-testid={makeTestId(testId, '-title')}
6881
>
69-
{subtitle}
82+
{title.text}
7083
</Text.Body.Small>
71-
</Box>
72-
</Flex>
84+
</Flex>
85+
)}
7386
</Flex>
7487
);
7588
};

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type { WalletType } from './profile-dropdown.data';
1616
export type Props = Omit<ComponentPropsWithoutRef<'button'>, 'type'> & {
1717
disabled?: boolean;
1818
title: string;
19-
subtitle: string;
19+
subtitle?: string;
2020
profile?: {
2121
imageSrc: string;
2222
fallbackText: string;
@@ -57,7 +57,7 @@ export const WalletOption = ({
5757
type={type}
5858
testId="wallet-option"
5959
/>
60-
{type !== 'shared' && (
60+
{type !== 'shared' && onOpenAccountsMenu && (
6161
<Box ml="$10">
6262
<Flex
6363
className={cx.icon}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ import * as cx from './profile-dropdown-wallet-status.css';
88
export interface Props {
99
status: 'error' | 'synced' | 'syncing';
1010
label: string;
11+
type?: 'button' | 'flat';
1112
}
1213

1314
export const WalletStatus = ({
1415
label,
1516
status,
17+
type = 'button',
1618
}: Readonly<Props>): JSX.Element => {
1719
return (
1820
<Flex
1921
alignItems="center"
2022
justifyContent="space-between"
2123
py="$8"
2224
px="$12"
23-
className={cx.button}
25+
className={type === 'button' ? cx.button : cx.flat}
2426
>
2527
<Flex
2628
className={cx.icon({

src/design-system/profile-dropdown/profile-dropdown-wallet-status.css.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export const button = style([
99
}),
1010
]);
1111

12+
export const flat = style([]);
13+
1214
export const icon = recipe({
1315
base: sx({
1416
w: '$10',

src/design-system/profile-dropdown/profile-dropdown.stories.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,28 @@ const WalletStatuses = (): JSX.Element => (
6969
</Variants.Row>
7070
);
7171

72+
const WalletStatusesFlat = (): JSX.Element => (
73+
<Variants.Row>
74+
<Variants.Cell>
75+
<WalletStatus type="flat" status="synced" label="Wallet synced (flat)" />
76+
</Variants.Cell>
77+
<Variants.Cell>
78+
<WalletStatus
79+
type="flat"
80+
status="syncing"
81+
label="Wallet syncing (flat)"
82+
/>
83+
</Variants.Cell>
84+
<Variants.Cell>
85+
<WalletStatus
86+
type="flat"
87+
status="error"
88+
label="Not synced to the blockchain (flat)"
89+
/>
90+
</Variants.Cell>
91+
</Variants.Row>
92+
);
93+
7294
export const Overview = (): JSX.Element => (
7395
<Grid columns="$1">
7496
<Cell>
@@ -81,11 +103,13 @@ export const Overview = (): JSX.Element => (
81103

82104
<Variants.Table headers={['Synced', 'Syncing', 'Not synced']}>
83105
<WalletStatuses />
106+
<WalletStatusesFlat />
84107
</Variants.Table>
85108

86109
<LocalThemeProvider colorScheme={ThemeColorScheme.Dark}>
87110
<Variants.Table>
88111
<WalletStatuses />
112+
<WalletStatusesFlat />
89113
</Variants.Table>
90114
</LocalThemeProvider>
91115
</Section>

0 commit comments

Comments
 (0)