Skip to content

Commit

Permalink
fix: Display token balance in dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Jun 22, 2023
1 parent e1227c9 commit 946e646
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
18 changes: 12 additions & 6 deletions src/components/tx-flow/flows/TokenTransfer/CreateTokenTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
CardActions,
Divider,
FormControl,
Grid,
InputLabel,
MenuItem,
SvgIcon,
Expand All @@ -34,7 +35,7 @@ import NumberField from '@/components/common/NumberField'
import { validateDecimalLength, validateLimitedAmount } from '@/utils/validation'
import { type TokenTransferParams, TokenTransferFields, TokenTransferType } from '.'
import TxCard from '../../common/TxCard'
import { safeFormatUnits } from '@/utils/formatters'
import { formatVisualAmount, safeFormatUnits } from '@/utils/formatters'
import commonCss from '@/components/tx-flow/common/styles.module.css'
import css from './styles.module.css'

Expand Down Expand Up @@ -200,12 +201,17 @@ const CreateTokenTransfer = ({
>
{balancesItems.map((item) => (
<MenuItem key={item.tokenInfo.address} value={item.tokenInfo.address}>
<div className={css.item}>
<Grid container alignItems="center" gap={1}>
<TokenIcon logoUri={item.tokenInfo.logoUri} tokenSymbol={item.tokenInfo.symbol} />
<Typography>
<b>{item.tokenInfo.symbol}</b>
</Typography>
</div>

<Grid item xs>
<Typography variant="body2">{item.tokenInfo.name}</Typography>

<Typography variant="caption" component="p">
{formatVisualAmount(item.balance, item.tokenInfo.decimals)} {item.tokenInfo.symbol}
</Typography>
</Grid>
</Grid>
</MenuItem>
))}
</TextField>
Expand Down
15 changes: 6 additions & 9 deletions src/components/tx-flow/flows/TokenTransfer/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
}

.amount {
min-width: 130px;
flex-grow: 1;
}

.amount :global(.MuiInput-input) {
padding-left: var(--space-3);
padding-left: var(--space-2);
}

.max {
Expand All @@ -40,6 +41,10 @@
padding: var(--space-2);
}

.select {
flex-shrink: 0;
}

.select :global(.MuiSelect-select) {
margin: var(--space-1);
display: flex;
Expand All @@ -52,14 +57,6 @@
margin-right: var(--space-2);
}

.item {
display: inline-flex;
gap: 6px;
align-items: center;
padding-top: 2px;
padding-bottom: 2px;
}

.token {
display: flex;
justify-content: center;
Expand Down

0 comments on commit 946e646

Please sign in to comment.