Skip to content

Commit

Permalink
fix: long token name visible over balance
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaik-Sirajuddin committed Aug 28, 2024
1 parent d4f4d6d commit aab69ba
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/components/common/TokenAmount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const TokenAmount = ({
direction,
fallbackSrc,
preciseAmount,
truncateText = false,
}: {
value: string
decimals?: number
Expand All @@ -24,6 +25,7 @@ const TokenAmount = ({
direction?: TransferDirection
fallbackSrc?: string
preciseAmount?: boolean
truncateText?: boolean
}): ReactElement => {
const sign = direction === TransferDirection.OUTGOING ? '-' : ''
const amount =
Expand All @@ -33,9 +35,9 @@ const TokenAmount = ({

return (
<Tooltip title={fullAmount}>
<span className={classNames(css.container, { [css.verticalAlign]: logoUri })}>
<span className={classNames(css.container, { [css.verticalAlign]: logoUri }, { [css.w100]: truncateText })}>
{logoUri && <TokenIcon logoUri={logoUri} tokenSymbol={tokenSymbol} fallbackSrc={fallbackSrc} />}
<b>
<b className={classNames(css.ellipsisText, { [css.w100]: truncateText })}>
{sign}
{amount} {tokenSymbol}
</b>
Expand Down
8 changes: 8 additions & 0 deletions src/components/common/TokenAmount/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
gap: var(--space-1);
color: var(--color-text-primary);
}
.w100{
width: 100%;
}

.verticalAlign {
vertical-align: middle;
}

.ellipsisText {
overflow: hidden;
text-overflow: ellipsis;
}
7 changes: 6 additions & 1 deletion src/components/transactions/TxInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ export const TransferTx = ({
omitSign = false,
withLogo = true,
preciseAmount = false,
truncateText = false,
}: {
info: Transfer
omitSign?: boolean
withLogo?: boolean
preciseAmount?: boolean
truncateText?: boolean
}): ReactElement => {
const chainConfig = useCurrentChain()
const { nativeCurrency } = chainConfig || {}
Expand All @@ -49,6 +51,7 @@ export const TransferTx = ({
tokenSymbol={nativeCurrency?.symbol}
logoUri={withLogo ? nativeCurrency?.logoUri : undefined}
preciseAmount={preciseAmount}
truncateText={truncateText}
/>
)
}
Expand All @@ -60,6 +63,7 @@ export const TransferTx = ({
direction={direction}
logoUri={withLogo ? transfer?.logoUri : undefined}
preciseAmount={preciseAmount}
truncateText={truncateText}
/>
)
}
Expand All @@ -77,6 +81,7 @@ export const TransferTx = ({
direction={undefined}
logoUri={withLogo ? transfer?.logoUri : undefined}
fallbackSrc="/images/common/nft-placeholder.png"
truncateText={truncateText}
/>
)
}
Expand Down Expand Up @@ -121,7 +126,7 @@ const TxInfo = ({ info, ...rest }: { info: TransactionInfo; omitSign?: boolean;
}

if (isTransferTxInfo(info)) {
return <TransferTx info={info} {...rest} />
return <TransferTx info={info} {...rest} truncateText />
}

if (isCustomTxInfo(info)) {
Expand Down

0 comments on commit aab69ba

Please sign in to comment.