Skip to content

Commit

Permalink
No number wrap on the address 'Tokens' tab
Browse files Browse the repository at this point in the history
Fixes #1673
  • Loading branch information
tom2drum committed Mar 8, 2024
1 parent 760c69e commit f855e7e
Show file tree
Hide file tree
Showing 19 changed files with 38 additions and 16 deletions.
11 changes: 11 additions & 0 deletions mocks/address/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ export const erc20LongSymbol: AddressTokenBalance = {
token_instance: null,
};

export const erc20BigAmount: AddressTokenBalance = {
token: {
...tokens.tokenInfoERC20LongSymbol,
exchange_rate: '4200000000',
name: 'DuckDuckGoose Stable Coin',
},
token_id: null,
value: '39000000000000000000',
token_instance: null,
};

export const erc721a: AddressTokenBalance = {
token: tokens.tokenInfoERC721a,
token_id: null,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ui/address/tokenSelect/TokenSelect.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ base('long values', async({ mount, page }) => {
}), { times: 1 });
await page.route(TOKENS_ERC20_API_URL, async(route) => route.fulfill({
status: 200,
body: JSON.stringify({ items: [ tokensMock.erc20LongSymbol ] }),
body: JSON.stringify({ items: [ tokensMock.erc20LongSymbol, tokensMock.erc20BigAmount ] }),
}), { times: 1 });
await page.route(TOKENS_ERC721_API_URL, async(route) => route.fulfill({
status: 200,
Expand Down
12 changes: 11 additions & 1 deletion ui/address/tokenSelect/TokenSelectButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';

import type { FormattedData } from './types';

import { space } from 'lib/html-entities';
import * as mixpanel from 'lib/mixpanel/index';
import IconSvg from 'ui/shared/IconSvg';

Expand Down Expand Up @@ -42,7 +43,16 @@ const TokenSelectButton = ({ isOpen, isLoading, onClick, data }: Props, ref: Rea
>
<IconSvg name="tokens" boxSize={ 4 } mr={ 2 }/>
<Text fontWeight={ 600 }>{ prefix }{ num }</Text>
<Text whiteSpace="pre" variant="secondary" fontWeight={ 400 }> ({ prefix }${ usd.toFormat(2) })</Text>
<Text
whiteSpace="pre"
variant="secondary"
fontWeight={ 400 }
maxW={{ base: 'calc(100vw - 230px)', lg: '500px' }}
overflow="hidden"
textOverflow="ellipsis"
>
{ space }({ prefix }${ usd.toFormat(2) })
</Text>
<IconSvg name="arrows/east-mini" transform={ isOpen ? 'rotate(90deg)' : 'rotate(-90deg)' } transitionDuration="faster" boxSize={ 5 } ml={ 3 }/>
</Button>
{ isLoading && !isOpen && <Skeleton h="100%" w="100%" position="absolute" top={ 0 } left={ 0 } bgColor={ skeletonBgColor } borderRadius="base"/> }
Expand Down
6 changes: 2 additions & 4 deletions ui/address/tokenSelect/TokenSelectDesktop.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useColorModeValue, Popover, PopoverTrigger, PopoverContent, PopoverBody, useDisclosure } from '@chakra-ui/react';
import { Popover, PopoverTrigger, PopoverContent, PopoverBody, useDisclosure } from '@chakra-ui/react';
import React from 'react';

import type { FormattedData } from './types';
Expand All @@ -15,8 +15,6 @@ interface Props {
const TokenSelectDesktop = ({ data, isLoading }: Props) => {
const { isOpen, onToggle, onClose } = useDisclosure();

const bgColor = useColorModeValue('white', 'gray.900');

const result = useTokenSelect(data);

return (
Expand All @@ -25,7 +23,7 @@ const TokenSelectDesktop = ({ data, isLoading }: Props) => {
<TokenSelectButton isOpen={ isOpen } onClick={ onToggle } data={ result.data } isLoading={ isLoading }/>
</PopoverTrigger>
<PopoverContent w="355px" maxH="450px" overflowY="scroll">
<PopoverBody px={ 4 } py={ 6 } bgColor={ bgColor } boxShadow="2xl" >
<PopoverBody px={ 4 } py={ 6 } boxShadow="2xl" >
<TokenSelectMenu { ...result }/>
</PopoverBody>
</PopoverContent>
Expand Down
9 changes: 6 additions & 3 deletions ui/address/tokenSelect/TokenSelectItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { chakra, Flex, Text, useColorModeValue } from '@chakra-ui/react';
import { chakra, Flex, useColorModeValue } from '@chakra-ui/react';
import BigNumber from 'bignumber.js';
import React from 'react';

Expand Down Expand Up @@ -62,7 +62,7 @@ const TokenSelectItem = ({ data }: Props) => {
_hover={{
bgColor: useColorModeValue('blue.50', 'gray.800'),
}}
color="initial"
color="unset"
fontSize="sm"
href={ url }
>
Expand All @@ -73,8 +73,11 @@ const TokenSelectItem = ({ data }: Props) => {
noCopy
noLink
fontWeight={ 700 }
mr={ 2 }
/>
{ data.usd && <Text fontWeight={ 700 } ml="auto">${ data.usd.toFormat(2) }</Text> }
{ data.usd && (
<TruncatedValue value={ `$${ data.usd.toFormat(2) }` } fontWeight={ 700 } minW="120px" ml="auto" textAlign="right"/>
) }
</Flex>
<Flex alignItems="center" justifyContent="space-between" w="100%" whiteSpace="nowrap">
{ secondRow }
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions ui/address/tokens/ERC20TokensListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ const ERC20TokensListItem = ({ token, value, isLoading }: Props) => {
</Skeleton>
</HStack>
) }
<HStack spacing={ 3 }>
<HStack spacing={ 3 } alignItems="baseline">
<Skeleton isLoaded={ !isLoading } fontSize="sm" fontWeight={ 500 }>Quantity</Skeleton>
<Skeleton isLoaded={ !isLoading } fontSize="sm" color="text_secondary">
<Skeleton isLoaded={ !isLoading } fontSize="sm" color="text_secondary" whiteSpace="pre-wrap" wordBreak="break-word">
<span>{ tokenQuantity }</span>
</Skeleton>
</HStack>
{ tokenValue !== undefined && (
<HStack spacing={ 3 }>
<HStack spacing={ 3 } alignItems="baseline">
<Skeleton isLoaded={ !isLoading } fontSize="sm" fontWeight={ 500 }>Value</Skeleton>
<Skeleton isLoaded={ !isLoading } fontSize="sm" color="text_secondary">
<span>{ tokenValue }</span>
<Skeleton isLoaded={ !isLoading } fontSize="sm" color="text_secondary" whiteSpace="pre-wrap" wordBreak="break-word">
<span>${ tokenValue }</span>
</Skeleton>
</HStack>
) }
Expand Down
4 changes: 2 additions & 2 deletions ui/address/tokens/TokenBalancesItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const TokenBalancesItem = ({ name, value, isLoading }: {name: string; value: str

return (
<Flex p={ 5 } bgColor={ bgColor } borderRadius="16px" alignItems="center">
<IconSvg name="wallet" boxSize="30px" mr={ 3 }/>
<IconSvg name="wallet" boxSize="30px" mr={ 3 } flexShrink={ 0 }/>
<Box>
<Text variant="secondary" fontSize="xs">{ name }</Text>
<Skeleton isLoaded={ !isLoading } fontWeight="500">{ value }</Skeleton>
<Skeleton isLoaded={ !isLoading } fontWeight="500" whiteSpace="pre-wrap" wordBreak="break-word">{ value }</Skeleton>
</Box>
</Flex>
);
Expand Down

0 comments on commit f855e7e

Please sign in to comment.