Skip to content

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

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 10, 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
1 change: 1 addition & 0 deletions src/design-system/asset-input/asset-input.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const AssetInput = ({
<Box className={cx.assetNameBox}>
<TickerButton
id={state.asset.id}
icon={state.asset.icon}
name={state.asset.ticker}
onClick={(): void => {
onTickerClick?.(state.asset);
Expand Down
1 change: 1 addition & 0 deletions src/design-system/asset-input/asset-input.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface Asset {
ticker: string;
balance: string;
amount: string;
icon?: string;
}

export interface AssetWithFiat extends Asset {
Expand Down
3 changes: 3 additions & 0 deletions src/design-system/asset-input/asset-input.fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import cardanoImage from '../../assets/images/cardano-blue-bg.png';

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

export const asset: AssetWithFiat = {
balance: String(10_000_000),
amount: '',
id: '',
ticker: 'Token',
icon: cardanoImage,
fiat: {
value: '0',
ticker: 'USD',
Expand Down
18 changes: 12 additions & 6 deletions src/design-system/asset-input/ticker-button.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,37 @@ import React from 'react';
import ChevronRight from '@icons/ChevronRightComponent';

import { Flex } from '../flex';
import { Image } from '../profile-picture';
import { Text } from '../text';

import * as cx from './ticker-button.css';

interface Props {
name: string;
id: string;
icon?: string;
onClick?: () => void;
}

export const TickerButton = ({
name,
id,
icon,
onClick,
}: Readonly<Props>): JSX.Element => (
<button
className={cx.button}
onClick={onClick}
data-testid={`asset-input-ticker-button-${id}`}
>
<Text.SubHeading weight="$bold">
<Flex justifyContent="center" alignItems="center">
{name}
<ChevronRight className={cx.chevronIcon} />
</Flex>
</Text.SubHeading>
<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>
);
4 changes: 2 additions & 2 deletions src/design-system/asset-input/ticker-button.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const button = style({
});

export const chevronIcon = sx({
w: '$16',
h: '$16',
w: '$auto',
h: '$auto',
marginLeft: '$8',
});