Skip to content

Commit e424a0f

Browse files
committed
feat: improve simple asset input [LW-9231]
1 parent 24bc1b2 commit e424a0f

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ interface Props {
1010
onChange?: (value: string) => void;
1111
value?: string;
1212
id: string;
13+
testId?: string;
1314
}
1415

1516
export const AmountInput = ({
1617
alignment = 'right',
1718
onChange,
1819
value,
1920
id,
21+
testId,
2022
}: Readonly<Props>): JSX.Element => {
2123
return (
2224
<Box className={cx.amountInputSizer} data-value={value}>
@@ -26,7 +28,7 @@ export const AmountInput = ({
2628
size={1}
2729
onChange={({ target }): void => onChange?.(target.value)}
2830
placeholder="0.0"
29-
data-testid={`asset-input-amount-input-${id}`}
31+
data-testid={testId ?? `asset-input-amount-input-${id}`}
3032
/>
3133
</Box>
3234
);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export { AssetInput } from './asset-input.component';
22
export { SimpleAssetInput } from './simple-asset-input.component';
3-
export * as Data from './asset-input.data';
3+
export * from './asset-input.data';

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ interface Props {
1212
state: AssetState<Asset>;
1313
balanceLabel: string;
1414
onAmountChange?: (asset: Readonly<Asset>, amount: string) => void;
15+
testId?: string;
1516
}
1617

1718
export const SimpleAssetInput = ({
1819
state,
1920
balanceLabel,
2021
onAmountChange,
22+
testId,
2123
}: Readonly<Props>): JSX.Element => (
2224
<div className={cx.root}>
2325
<Box className={cx.amountBox}>
@@ -28,6 +30,7 @@ export const SimpleAssetInput = ({
2830
onChange={(value): void => {
2931
onAmountChange?.(state.asset, value);
3032
}}
33+
testId={testId}
3134
/>
3235
</Box>
3336
<Box className={cx.balance}>

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,21 @@ import type { PropsWithChildren } from 'react';
33

44
import PlusSmall from '@icons/PlusSmallComponent';
55

6-
import { AssetInput } from '../asset-input';
6+
import { AssetInput, AssetState, AssetWithFiat } from '../asset-input';
77
import { Box } from '../box';
88
import * as ControlButtons from '../control-buttons';
99
import { Divider } from '../divider';
1010

1111
import * as cx from './bundle-input.css';
1212
import { RemoveButton } from './remove-button.component';
1313

14-
import type { Data } from '../asset-input';
15-
1614
export type Props = PropsWithChildren<{
17-
state?: Data.AssetState[];
15+
state?: AssetState[];
1816
onAddAsset?: () => void;
19-
onRemoveAsset?: (asset: Readonly<Data.AssetWithFiat>) => void;
20-
onAmountChange?: (
21-
asset: Readonly<Data.AssetWithFiat>,
22-
amount: string,
23-
) => void;
24-
onTickerClick?: (asset: Readonly<Data.AssetWithFiat>) => void;
25-
onMaxClick?: (asset: Readonly<Data.AssetWithFiat>) => void;
17+
onRemoveAsset?: (asset: Readonly<AssetWithFiat>) => void;
18+
onAmountChange?: (asset: Readonly<AssetWithFiat>, amount: string) => void;
19+
onTickerClick?: (asset: Readonly<AssetWithFiat>) => void;
20+
onMaxClick?: (asset: Readonly<AssetWithFiat>) => void;
2621
}>;
2722

2823
export const BundleInput = ({

src/design-system/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export { Divider } from './divider';
66
export { Flex } from './flex';
77
export { Grid, Cell } from './grid';
88
export { Text } from './text';
9-
export { AssetInput, SimpleAssetInput } from './asset-input';
9+
export * from './asset-input';
1010
export { BundleInput } from './bundle-input';
1111
export * as SubNavigation from './sub-navigation';
1212
export * as NavigationButton from './navigation-buttons';

0 commit comments

Comments
 (0)