Skip to content

feat: [lw-12215] add asset icon component into asset input #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025
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
4 changes: 3 additions & 1 deletion src/design-system/asset-input/asset-input.data.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react';

export interface Asset {
id: string;
ticker: string;
balance: string;
amount: string;
icon?: string;
icon?: string | React.ReactNode;
}

export interface AssetWithFiat extends Asset {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import React from 'react';

import cardanoImage from '../../assets/images/cardano-blue-bg.png';
import { Image } from '../profile-picture';

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

Expand All @@ -7,7 +10,7 @@ export const asset: AssetWithFiat = {
amount: '',
id: '',
ticker: 'Token',
icon: cardanoImage,
icon: <Image imageSrc={cardanoImage} />,
fiat: {
value: '0',
ticker: 'USD',
Expand Down
40 changes: 22 additions & 18 deletions src/design-system/asset-input/ticker-button.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as cx from './ticker-button.css';
interface Props {
name: string;
id: string;
icon?: string;
icon?: string | React.ReactNode;
onClick?: () => void;
}

Expand All @@ -20,20 +20,24 @@ export const TickerButton = ({
id,
icon,
onClick,
}: Readonly<Props>): JSX.Element => (
<button
className={cx.button}
onClick={onClick}
data-testid={`asset-input-ticker-button-${id}`}
>
<Flex alignItems="center" gap="$16">
{icon && <Image imageSrc={icon} alt="Token" />}
<Text.SubHeading weight="$bold">
<Flex justifyContent="center" alignItems="center">
<span>{name}</span>
<ChevronRight className={cx.chevronIcon} />
</Flex>
</Text.SubHeading>
</Flex>
</button>
);
}: Readonly<Props>): JSX.Element => {
const isIconString = typeof icon === 'string';

return (
<button
className={cx.button}
onClick={onClick}
data-testid={`asset-input-ticker-button-${id}`}
>
<Flex alignItems="center" gap="$16">
{isIconString ? <Image imageSrc={icon} alt="Token" /> : icon}
<Text.SubHeading weight="$bold">
<Flex justifyContent="center" alignItems="center">
<span>{name}</span>
<ChevronRight className={cx.chevronIcon} />
</Flex>
</Text.SubHeading>
</Flex>
</button>
);
};