Skip to content

Commit cceba5e

Browse files
authored
Merge pull request #98 from input-output-hk/feat/lw-12217-optional-fiat-in-asset-input-and-badge-in-table
make fiat optional in asset input, add badge into asset table [lw-12577]
2 parents 2a30be3 + 0e4c88a commit cceba5e

File tree

9 files changed

+55
-17
lines changed

9 files changed

+55
-17
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ export const AssetInput = ({
3636
</Box>
3737
<Box className={cx.amountBox}>
3838
<Flex alignItems="center" justifyContent="flex-end">
39-
<MaxButton
40-
label="MAX"
41-
data-testid={`asset-input-max-button-${state.asset.id}`}
42-
onClick={(): void => {
43-
onMaxClick?.(state.asset);
44-
}}
45-
/>
39+
{!!onMaxClick && (
40+
<MaxButton
41+
label="MAX"
42+
data-testid={`asset-input-max-button-${state.asset.id}`}
43+
onClick={(): void => {
44+
onMaxClick?.(state.asset);
45+
}}
46+
/>
47+
)}
4648
<Box ml="$8">
4749
<AmountInput
4850
id={state.asset.id}
@@ -65,9 +67,11 @@ export const AssetInput = ({
6567
alignItems="flex-end"
6668
justifyContent="flex-end"
6769
>
68-
<Text.Body.Normal color="secondary">
69-
{state.asset.fiat.value} {state.asset.fiat.ticker}
70-
</Text.Body.Normal>
70+
{!!state.asset.fiat && (
71+
<Text.Body.Normal color="secondary">
72+
{state.asset.fiat.value} {state.asset.fiat.ticker}
73+
</Text.Body.Normal>
74+
)}
7175
{state.type === 'invalid' && (
7276
<Text.Label
7377
color="error"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface Asset {
66
}
77

88
export interface AssetWithFiat extends Asset {
9-
fiat: {
9+
fiat?: {
1010
value: string;
1111
ticker: string;
1212
};

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

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

33
import ChevronRight from '@icons/ChevronRightComponent';
44

5+
import { Flex } from '../flex';
56
import { Text } from '../text';
67

78
import * as cx from './ticker-button.css';
@@ -23,8 +24,10 @@ export const TickerButton = ({
2324
data-testid={`asset-input-ticker-button-${id}`}
2425
>
2526
<Text.SubHeading weight="$bold">
26-
{name}
27-
<ChevronRight className={cx.chevronIcon} />
27+
<Flex justifyContent="center" alignItems="center">
28+
{name}
29+
<ChevronRight className={cx.chevronIcon} />
30+
</Flex>
2831
</Text.SubHeading>
2932
</button>
3033
);

src/design-system/assets-table/assets-table-token-profile.component.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { ReactElement, ReactNode } from 'react';
22

33
import { Box } from '../box';
4+
import { Flex } from '../flex';
45
import { Grid, Cell } from '../grid';
56
import { Image } from '../profile-picture';
67
import { Text } from '../text';
@@ -16,6 +17,7 @@ type TokenProfileProps = {
1617
alt?: string;
1718
image: ReactNode;
1819
name: ReactNode;
20+
badge?: string;
1921
description: ReactNode;
2022
testId?: string;
2123
};
@@ -24,6 +26,7 @@ export const TokenProfile = ({
2426
alt,
2527
image,
2628
name,
29+
badge,
2730
description,
2831
testId = 'token-profile',
2932
}: Readonly<TokenProfileProps>): ReactElement => {
@@ -45,9 +48,20 @@ export const TokenProfile = ({
4548
<Box mr="$24">{imageNode}</Box>
4649
</Cell>
4750
<Cell>
48-
<Text.Body.Large weight="$semibold" data-testid={`${testId}-name`}>
49-
{name}
50-
</Text.Body.Large>
51+
<Flex alignItems="center" gap="$8">
52+
<Text.Body.Large weight="$semibold" data-testid={`${testId}-name`}>
53+
{name}
54+
</Text.Body.Large>
55+
{!!badge && (
56+
<Text.Label
57+
className={cx.badge}
58+
weight="$medium"
59+
data-testid={`${testId}-badge`}
60+
>
61+
{badge}
62+
</Text.Label>
63+
)}
64+
</Flex>
5165
<Box>
5266
<Text.Body.Normal
5367
color="secondary"
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
import { style } from '../../design-tokens';
1+
import { style, vars } from '../../design-tokens';
22

33
export const container = style({
44
gridArea: 'tokenProfile',
55
});
6+
7+
export const badge = style({
8+
backgroundColor: vars.colors.$assets_table_badge_bgColor,
9+
borderRadius: vars.radius.$medium,
10+
padding: `0 ${vars.spacing.$4}`,
11+
color: vars.colors.$assets_table_badge_textColor,
12+
});

src/design-system/assets-table/assets-table.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ export const Controls: Controls = ({
203203
image={cardanoImage}
204204
name={tokenName}
205205
description={tokenSubtitle}
206+
badge="Badge"
206207
/>
207208
<MarketPrice
208209
tokenPrice={tokenPrice}

src/design-tokens/colors.data.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ export const colors = {
109109

110110
$assets_table_container_bgColor_hover: '',
111111

112+
$assets_table_badge_bgColor: '',
113+
$assets_table_badge_textColor: '',
114+
112115
$dialog_container_bgColor: '',
113116
$dialog_description_color: '',
114117

src/design-tokens/theme/dark-theme.css.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ const colors: Colors = {
167167

168168
$assets_table_container_bgColor_hover: darkColorScheme.$primary_mid_grey,
169169

170+
$assets_table_badge_bgColor: '#0000FE',
171+
$assets_table_badge_textColor: lightColorScheme.$primary_white,
172+
170173
$dialog_container_bgColor: darkColorScheme.$primary_light_black,
171174
$dialog_description_color: darkColorScheme.$primary_light_grey,
172175

src/design-tokens/theme/light-theme.css.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ const colors: Colors = {
180180

181181
$assets_table_container_bgColor_hover: lightColorScheme.$primary_light_grey,
182182

183+
$assets_table_badge_bgColor: '#0000FE',
184+
$assets_table_badge_textColor: lightColorScheme.$primary_white,
185+
183186
$dialog_container_bgColor: lightColorScheme.$primary_white,
184187
$dialog_description_color: lightColorScheme.$primary_black,
185188

0 commit comments

Comments
 (0)