Skip to content

Commit 4c762bd

Browse files
authored
Merge pull request #70 from input-output-hk/feat/add-edit-to-wallet-option
feat: add edit to wallet option
2 parents d44db8c + 2e4be3d commit 4c762bd

File tree

6 files changed

+78
-14
lines changed

6 files changed

+78
-14
lines changed

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

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import type { ComponentPropsWithoutRef } from 'react';
22
import React from 'react';
33

44
import ChevronRight from '@icons/ChevronRightThinComponent';
5+
import EditComponent from '@icons/EditComponent';
56
import classNames from 'classnames';
67

7-
import { Box } from '../box';
88
import { Icon as IconButton } from '../control-buttons';
99
import { Flex } from '../flex';
1010

@@ -21,6 +21,7 @@ export type Props = Omit<ComponentPropsWithoutRef<'button'>, 'type'> & {
2121
profile?: ProfileType;
2222
type: WalletType;
2323
onOpenAccountsMenu?: () => void;
24+
onOpenEditWallet?: () => void;
2425
};
2526

2627
export const WalletOption = ({
@@ -32,6 +33,7 @@ export const WalletOption = ({
3233
profile,
3334
type,
3435
onOpenAccountsMenu,
36+
onOpenEditWallet,
3537
...props
3638
}: Readonly<Props>): JSX.Element => {
3739
return (
@@ -53,15 +55,23 @@ export const WalletOption = ({
5355
type={type}
5456
testId="wallet-option"
5557
/>
56-
{type !== 'shared' && onOpenAccountsMenu && (
57-
<Box ml="$10">
58-
<Flex
59-
className={cx.icon}
60-
w="$24"
61-
h="$24"
62-
alignItems="center"
63-
justifyContent="center"
64-
>
58+
<Flex ml="$10" gap="$4">
59+
{onOpenEditWallet && (
60+
<Flex w="$24" h="$24" alignItems="center" justifyContent="center">
61+
<IconButton
62+
onClick={(event): void => {
63+
onOpenEditWallet?.();
64+
event.stopPropagation();
65+
}}
66+
icon={<EditComponent />}
67+
size="extraSmall"
68+
as="div"
69+
testId="wallet-option-edit-wallet-button"
70+
/>
71+
</Flex>
72+
)}
73+
{type !== 'shared' && onOpenAccountsMenu && (
74+
<Flex w="$24" h="$24" alignItems="center" justifyContent="center">
6575
<IconButton
6676
onClick={(event): void => {
6777
onOpenAccountsMenu?.();
@@ -73,8 +83,8 @@ export const WalletOption = ({
7383
testId="wallet-option-accounts-menu-button"
7484
/>
7585
</Flex>
76-
</Box>
77-
)}
86+
)}
87+
</Flex>
7888
</Flex>
7989
</button>
8090
);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,3 @@ export const container = style([
4242
},
4343
},
4444
]);
45-
46-
export const icon = style({});

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22

3+
import { action } from '@storybook/addon-actions';
34
import type { Meta } from '@storybook/react';
45

56
import { page, Variants, Section, UIStateTable } from '../decorators';
@@ -91,6 +92,45 @@ export const Overview = (): JSX.Element => (
9192

9293
<Divider my="$64" />
9394

95+
<Section title="Example with actions">
96+
<Flex flexDirection="column" alignItems="center" w="$fill">
97+
<Variants.Table
98+
headers={['Hot wallet', 'Cold wallet', 'Shared wallet']}
99+
>
100+
<Variants.Row>
101+
<Variants.Cell>
102+
<WalletOption
103+
title="Alice's wallet"
104+
subtitle="Account #0"
105+
type="hot"
106+
onOpenAccountsMenu={action('onOpenAccountsMenu')}
107+
onOpenEditWallet={action('onOpenEditWallet')}
108+
/>
109+
</Variants.Cell>
110+
<Variants.Cell>
111+
<WalletOption
112+
title="Alice's wallet"
113+
subtitle="Account #0"
114+
type="cold"
115+
onOpenAccountsMenu={action('onOpenAccountsMenu')}
116+
onOpenEditWallet={action('onOpenEditWallet')}
117+
/>
118+
</Variants.Cell>
119+
<Variants.Cell>
120+
<WalletOption
121+
title="Shared Wallet"
122+
subtitle="Lace Team"
123+
type="shared"
124+
onOpenEditWallet={action('onOpenEditWallet')}
125+
/>
126+
</Variants.Cell>
127+
</Variants.Row>
128+
</Variants.Table>
129+
</Flex>
130+
</Section>
131+
132+
<Divider my="$64" />
133+
94134
<Section title="Main components">
95135
<UIStateTable>
96136
<WalletOptionUIStates />

src/icons/EditComponent.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as React from 'react';
2+
import type { SVGProps } from 'react';
3+
4+
const SvgEditComponent = (props: SVGProps<SVGSVGElement>) => (
5+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
6+
<path
7+
d="M12.5932 3.4068L13.0351 2.96486V2.96486L12.5932 3.4068ZM4.94445 13.0197V13.6447C5.11021 13.6447 5.26918 13.5789 5.38639 13.4617L4.94445 13.0197ZM3 13.0197H2.375C2.375 13.3649 2.65482 13.6447 3 13.6447V13.0197ZM3 11.0358L2.55806 10.5939C2.44085 10.7111 2.375 10.87 2.375 11.0358H3ZM11.071 3.84874C11.3693 3.55042 11.8529 3.55042 12.1513 3.84874L13.0351 2.96486C12.2487 2.17838 10.9735 2.17838 10.1871 2.96486L11.071 3.84874ZM12.1513 3.84874C12.4496 4.14706 12.4496 4.63073 12.1513 4.92905L13.0351 5.81293C13.8216 5.02646 13.8216 3.75133 13.0351 2.96486L12.1513 3.84874ZM12.1513 4.92905L4.50251 12.5778L5.38639 13.4617L13.0351 5.81293L12.1513 4.92905ZM4.94445 12.3947H3V13.6447H4.94445V12.3947ZM10.1871 2.96486L2.55806 10.5939L3.44194 11.4777L11.071 3.84874L10.1871 2.96486ZM2.375 11.0358V13.0197H3.625V11.0358H2.375ZM9.35373 4.68208L11.3179 6.64627L12.2018 5.76238L10.2376 3.79819L9.35373 4.68208Z"
8+
fill="#3D3B39"
9+
/>
10+
</svg>
11+
);
12+
export default SvgEditComponent;

src/icons/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@ export { default as WalletComponent } from './WalletComponent';
7878
export { default as WarningIconCircleComponent } from './WarningIconCircleComponent';
7979
export { default as WarningIconTriangleSolidComponent } from './WarningIconTriangleSolidComponent';
8080
export { default as WarningIconTriangleComponent } from './WarningIconTriangleComponent';
81+
export { default as EditComponent } from './EditComponent';

src/icons/raw/edit.component.svg

Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)