Skip to content

Commit

Permalink
Feat: added clear button for asset input (#1027)
Browse files Browse the repository at this point in the history
* feat(AssetInput): added clear button for asset input

* feat(AssetInput): update position for clear button

* feat(AssetInput): use correct icon components; fine-tuned styling

* feat(AssetInput): removed size variable from IconButton

* fix(AssetInput): updated condition to disable clear button

* feat(AssetInput): updated hover color styling for clear button

* feat(AssetInput): add text-overflow ellipsis style to input
  • Loading branch information
MatthewCYLau authored Aug 19, 2022
1 parent 4c7f61f commit d820aef
Showing 1 changed file with 24 additions and 0 deletions.
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

2 comments on commit d820aef

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

Please sign in to comment.