Skip to content

make fiat optional in asset input, add badge into asset table [lw-12577] #98

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
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
24 changes: 14 additions & 10 deletions src/design-system/asset-input/asset-input.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ export const AssetInput = ({
</Box>
<Box className={cx.amountBox}>
<Flex alignItems="center" justifyContent="flex-end">
<MaxButton
label="MAX"
data-testid={`asset-input-max-button-${state.asset.id}`}
onClick={(): void => {
onMaxClick?.(state.asset);
}}
/>
{!!onMaxClick && (
<MaxButton
label="MAX"
data-testid={`asset-input-max-button-${state.asset.id}`}
onClick={(): void => {
onMaxClick?.(state.asset);
}}
/>
)}
<Box ml="$8">
<AmountInput
id={state.asset.id}
Expand All @@ -65,9 +67,11 @@ export const AssetInput = ({
alignItems="flex-end"
justifyContent="flex-end"
>
<Text.Body.Normal color="secondary">
≈ {state.asset.fiat.value} {state.asset.fiat.ticker}
</Text.Body.Normal>
{!!state.asset.fiat && (
<Text.Body.Normal color="secondary">
≈ {state.asset.fiat.value} {state.asset.fiat.ticker}
</Text.Body.Normal>
)}
{state.type === 'invalid' && (
<Text.Label
color="error"
Expand Down
2 changes: 1 addition & 1 deletion src/design-system/asset-input/asset-input.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface Asset {
}

export interface AssetWithFiat extends Asset {
fiat: {
fiat?: {
value: string;
ticker: string;
};
Expand Down
7 changes: 5 additions & 2 deletions src/design-system/asset-input/ticker-button.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';

import ChevronRight from '@icons/ChevronRightComponent';

import { Flex } from '../flex';
import { Text } from '../text';

import * as cx from './ticker-button.css';
Expand All @@ -23,8 +24,10 @@ export const TickerButton = ({
data-testid={`asset-input-ticker-button-${id}`}
>
<Text.SubHeading weight="$bold">
{name}
<ChevronRight className={cx.chevronIcon} />
<Flex justifyContent="center" alignItems="center">
{name}
<ChevronRight className={cx.chevronIcon} />
</Flex>
</Text.SubHeading>
</button>
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { ReactElement, ReactNode } from 'react';

import { Box } from '../box';
import { Flex } from '../flex';
import { Grid, Cell } from '../grid';
import { Image } from '../profile-picture';
import { Text } from '../text';
Expand All @@ -16,6 +17,7 @@ type TokenProfileProps = {
alt?: string;
image: ReactNode;
name: ReactNode;
badge?: string;
description: ReactNode;
testId?: string;
};
Expand All @@ -24,6 +26,7 @@ export const TokenProfile = ({
alt,
image,
name,
badge,
description,
testId = 'token-profile',
}: Readonly<TokenProfileProps>): ReactElement => {
Expand All @@ -45,9 +48,20 @@ export const TokenProfile = ({
<Box mr="$24">{imageNode}</Box>
</Cell>
<Cell>
<Text.Body.Large weight="$semibold" data-testid={`${testId}-name`}>
{name}
</Text.Body.Large>
<Flex alignItems="center" gap="$8">
<Text.Body.Large weight="$semibold" data-testid={`${testId}-name`}>
{name}
</Text.Body.Large>
{!!badge && (
<Text.Label
className={cx.badge}
weight="$medium"
data-testid={`${testId}-badge`}
>
{badge}
</Text.Label>
)}
</Flex>
<Box>
<Text.Body.Normal
color="secondary"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { style } from '../../design-tokens';
import { style, vars } from '../../design-tokens';

export const container = style({
gridArea: 'tokenProfile',
});

export const badge = style({
backgroundColor: vars.colors.$assets_table_badge_bgColor,
borderRadius: vars.radius.$medium,
padding: `0 ${vars.spacing.$4}`,
color: vars.colors.$assets_table_badge_textColor,
});
1 change: 1 addition & 0 deletions src/design-system/assets-table/assets-table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export const Controls: Controls = ({
image={cardanoImage}
name={tokenName}
description={tokenSubtitle}
badge="Badge"
/>
<MarketPrice
tokenPrice={tokenPrice}
Expand Down
3 changes: 3 additions & 0 deletions src/design-tokens/colors.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export const colors = {

$assets_table_container_bgColor_hover: '',

$assets_table_badge_bgColor: '',
$assets_table_badge_textColor: '',

$dialog_container_bgColor: '',
$dialog_description_color: '',

Expand Down
3 changes: 3 additions & 0 deletions src/design-tokens/theme/dark-theme.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ const colors: Colors = {

$assets_table_container_bgColor_hover: darkColorScheme.$primary_mid_grey,

$assets_table_badge_bgColor: '#0000FE',
$assets_table_badge_textColor: lightColorScheme.$primary_white,

$dialog_container_bgColor: darkColorScheme.$primary_light_black,
$dialog_description_color: darkColorScheme.$primary_light_grey,

Expand Down
3 changes: 3 additions & 0 deletions src/design-tokens/theme/light-theme.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ const colors: Colors = {

$assets_table_container_bgColor_hover: lightColorScheme.$primary_light_grey,

$assets_table_badge_bgColor: '#0000FE',
$assets_table_badge_textColor: lightColorScheme.$primary_white,

$dialog_container_bgColor: lightColorScheme.$primary_white,
$dialog_description_color: lightColorScheme.$primary_black,

Expand Down