Skip to content
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

Feat: added clear button for asset input #1027

Merged
merged 7 commits into from
Aug 19, 2022
24 changes: 24 additions & 0 deletions src/components/transactions/AssetInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Trans } from '@lingui/macro';
import {
Box,
Button,
IconButton,
FormControl,
InputBase,
ListItemText,
Expand All @@ -10,6 +11,7 @@ import {
SelectChangeEvent,
Typography,
} from '@mui/material';
import { XCircleIcon } from '@heroicons/react/solid';
import React, { ReactNode } from 'react';
import NumberFormat, { NumberFormatProps } from 'react-number-format';

Expand Down Expand Up @@ -138,6 +140,9 @@ export const AssetInput = <T extends Asset = Asset>({
lineHeight: '28,01px',
padding: 0,
height: '28px',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
overflow: 'hidden',
},
}}
// eslint-disable-next-line
Expand All @@ -146,6 +151,25 @@ export const AssetInput = <T extends Asset = Asset>({

{!onSelect || assets.length === 1 ? (
<Box sx={{ display: 'inline-flex', alignItems: 'center' }}>
{value !== '' && (
<IconButton
sx={{
minWidth: 0,
p: 0,
left: 8,
color: 'text.muted',
'&:hover': {
color: 'text.secondary',
},
}}
onClick={() => {
onChange && onChange('');
}}
disabled={disabled}
>
<XCircleIcon height={16} />
</IconButton>
)}
<TokenIcon
aToken={asset.aToken}
symbol={asset.iconSymbol || asset.symbol}
Expand Down