Skip to content

Commit ced0233

Browse files
authored
Merge pull request #109 from input-output-hk/feat/lw-12215-selected-tocket-icon-component
feat: [lw-12215] add asset icon component into asset input
2 parents ff47935 + 0a3668f commit ced0233

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

src/design-system/asset-input/asset-input.data.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import React from 'react';
2+
13
export interface Asset {
24
id: string;
35
ticker: string;
46
balance: string;
57
amount: string;
6-
icon?: string;
8+
icon?: string | React.ReactNode;
79
}
810

911
export interface AssetWithFiat extends Asset {

src/design-system/asset-input/asset-input.fixtures.ts renamed to src/design-system/asset-input/asset-input.fixtures.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import React from 'react';
2+
13
import cardanoImage from '../../assets/images/cardano-blue-bg.png';
4+
import { Image } from '../profile-picture';
25

36
import type { AssetWithFiat, AssetState } from './asset-input.data';
47

@@ -7,7 +10,7 @@ export const asset: AssetWithFiat = {
710
amount: '',
811
id: '',
912
ticker: 'Token',
10-
icon: cardanoImage,
13+
icon: <Image imageSrc={cardanoImage} />,
1114
fiat: {
1215
value: '0',
1316
ticker: 'USD',

src/design-system/asset-input/ticker-button.component.tsx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as cx from './ticker-button.css';
1111
interface Props {
1212
name: string;
1313
id: string;
14-
icon?: string;
14+
icon?: string | React.ReactNode;
1515
onClick?: () => void;
1616
}
1717

@@ -20,20 +20,24 @@ export const TickerButton = ({
2020
id,
2121
icon,
2222
onClick,
23-
}: Readonly<Props>): JSX.Element => (
24-
<button
25-
className={cx.button}
26-
onClick={onClick}
27-
data-testid={`asset-input-ticker-button-${id}`}
28-
>
29-
<Flex alignItems="center" gap="$16">
30-
{icon && <Image imageSrc={icon} alt="Token" />}
31-
<Text.SubHeading weight="$bold">
32-
<Flex justifyContent="center" alignItems="center">
33-
<span>{name}</span>
34-
<ChevronRight className={cx.chevronIcon} />
35-
</Flex>
36-
</Text.SubHeading>
37-
</Flex>
38-
</button>
39-
);
23+
}: Readonly<Props>): JSX.Element => {
24+
const isIconString = typeof icon === 'string';
25+
26+
return (
27+
<button
28+
className={cx.button}
29+
onClick={onClick}
30+
data-testid={`asset-input-ticker-button-${id}`}
31+
>
32+
<Flex alignItems="center" gap="$16">
33+
{isIconString ? <Image imageSrc={icon} alt="Token" /> : icon}
34+
<Text.SubHeading weight="$bold">
35+
<Flex justifyContent="center" alignItems="center">
36+
<span>{name}</span>
37+
<ChevronRight className={cx.chevronIcon} />
38+
</Flex>
39+
</Text.SubHeading>
40+
</Flex>
41+
</button>
42+
);
43+
};

0 commit comments

Comments
 (0)