Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit dbe43a8

Browse files
author
Andy Hook
authored
TokenAmount: Hold token space during image load
1 parent b53690a commit dbe43a8

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

src/components/TokenAmount/TokenAmount.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ const TokenAmount = React.memo(function TokenAmount({
4444
{amount && (
4545
<span
4646
css={`
47-
padding-right: ${size === 'large' ? 0.5 * GU : 0.25 * GU}px;
47+
margin-right: ${size === 'large' ? 0.5 * GU : 0.25 * GU}px;
4848
${textStyle(size === 'large' ? 'title2' : 'body2')};
4949
line-height: 1;
50-
${size === 'large' ? `transform: translateY(2px);` : ''}
5150
`}
5251
>
5352
{TokenAmountLib.format(amount, decimals, { digits: digits })}
@@ -60,19 +59,30 @@ const TokenAmount = React.memo(function TokenAmount({
6059
})
6160

6261
const Icon = function Icon({ address, chainId, iconUrl, size }) {
62+
const theme = useTheme()
6363
const token = useToken(chainId === 1 ? address : '')
6464
const { exists } = useImageExists(iconUrl || token.iconUrl)
6565
return (
66-
exists && (
67-
<img
68-
alt=""
69-
height={3 * GU}
70-
src={iconUrl || token.iconUrl}
71-
css={`
72-
padding-right: ${size === 'large' ? 1 * GU : 0.5 * GU}px;
73-
`}
74-
/>
75-
)
66+
<div
67+
css={`
68+
display: flex;
69+
width: ${3 * GU}px;
70+
height: ${3 * GU}px;
71+
margin-right: ${size === 'large' ? 1 * GU : 0.75 * GU}px;
72+
`}
73+
>
74+
{exists ? (
75+
<img alt="" width="100%" src={iconUrl || token.iconUrl} />
76+
) : (
77+
<div
78+
css={`
79+
flex: 1;
80+
border-radius: 100%;
81+
border: 2px solid ${theme.border};
82+
`}
83+
/>
84+
)}
85+
</div>
7686
)
7787
}
7888

0 commit comments

Comments
 (0)