Skip to content

Commit

Permalink
chore: add AssetPicker fallback text
Browse files Browse the repository at this point in the history
  • Loading branch information
micaelae committed Sep 5, 2024
1 parent 124472b commit 47e6a43
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,63 +184,74 @@ export function AssetPicker({
}}
title={handleAssetPickerTitle()}
>
<Box display={Display.Flex} alignItems={AlignItems.center} gap={3}>
<Box display={Display.Flex}>
<BadgeWrapper
badge={
<AvatarNetwork
size={AvatarNetworkSize.Xs}
name={selectedNetwork?.nickname ?? ''}
src={
selectedNetwork?.rpcPrefs?.imageUrl ??
(selectedNetwork?.chainId &&
CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP[
selectedNetwork.chainId
])
}
backgroundColor={
Object.entries({
[GOERLI_DISPLAY_NAME]: BackgroundColor.goerli,
[SEPOLIA_DISPLAY_NAME]: BackgroundColor.sepolia,
}).find(([tickerSubstring]) =>
selectedNetwork?.ticker?.includes(tickerSubstring),
)?.[1]
}
borderColor={
primaryTokenImage
? BorderColor.borderMuted
: BorderColor.borderDefault
}
{asset ? (
<Box display={Display.Flex} alignItems={AlignItems.center} gap={3}>
<Box display={Display.Flex}>
<BadgeWrapper
badge={
<AvatarNetwork
size={AvatarNetworkSize.Xs}
name={selectedNetwork?.nickname ?? ''}
src={
selectedNetwork?.rpcPrefs?.imageUrl ??
(selectedNetwork?.chainId &&
CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP[
selectedNetwork.chainId
])
}
backgroundColor={
Object.entries({
[GOERLI_DISPLAY_NAME]: BackgroundColor.goerli,
[SEPOLIA_DISPLAY_NAME]: BackgroundColor.sepolia,
}).find(([tickerSubstring]) =>
selectedNetwork?.ticker?.includes(tickerSubstring),
)?.[1]
}
borderColor={
primaryTokenImage
? BorderColor.borderMuted
: BorderColor.borderDefault
}
/>
}
>
<AvatarToken
borderRadius={isNFT ? BorderRadius.LG : BorderRadius.full}
src={primaryTokenImage ?? undefined}
size={AvatarTokenSize.Md}
name={symbol}
{...(isNFT && {
backgroundColor: BackgroundColor.transparent,
})}
/>
}
>
<AvatarToken
borderRadius={isNFT ? BorderRadius.LG : BorderRadius.full}
src={primaryTokenImage ?? undefined}
size={AvatarTokenSize.Md}
name={symbol}
{...(isNFT && { backgroundColor: BackgroundColor.transparent })}
/>
</BadgeWrapper>
</Box>
</BadgeWrapper>
</Box>

<Tooltip disabled={!isSymbolLong} title={symbol} position="bottom">
<Text className="asset-picker__symbol" variant={TextVariant.bodyMd}>
{formattedSymbol}
</Text>
{isNFT && asset?.tokenId && (
<Tooltip disabled={!isSymbolLong} title={symbol} position="bottom">
<Text
variant={TextVariant.bodySm}
color={TextColor.textAlternative}
className="asset-picker__symbol"
variant={TextVariant.bodyMd}
>
#
{String(asset.tokenId).length < ELLIPSIFY_LENGTH
? asset.tokenId
: ellipsify(String(asset.tokenId), 6, 4)}
{formattedSymbol}
</Text>
)}
</Tooltip>
</Box>
{isNFT && asset?.tokenId && (
<Text
variant={TextVariant.bodySm}
color={TextColor.textAlternative}
>
#
{String(asset.tokenId).length < ELLIPSIFY_LENGTH
? asset.tokenId
: ellipsify(String(asset.tokenId), 6, 4)}
</Text>
)}
</Tooltip>
</Box>
) : (
<Text className="asset-picker__fallback" variant={TextVariant.bodyMd}>
{t('swapSelectToken')}
</Text>
)}
</Button>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@
opacity: 1;
cursor: not-allowed;
}

&__fallback{
text-wrap: nowrap;
padding-left: 8px;
}
}

0 comments on commit 47e6a43

Please sign in to comment.