Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move native token value below Fiat within Token list #22601

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ui/components/app/asset-list/asset-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
showPrimaryCurrency,
showSecondaryCurrency,
} from '../../../../shared/modules/currency-display.utils';
import { roundToDecimalPlacesRemovingExtraZeroes } from '../../../helpers/utils/util';

const AssetList = ({ onClickAsset }) => {
const [showDetectedTokens, setShowDetectedTokens] = useState(false);
Expand Down Expand Up @@ -105,7 +106,10 @@ const AssetList = ({ onClickAsset }) => {

const { tokensWithBalances, totalFiatBalance, totalWeiBalance, loading } =
useAccountTotalFiatBalance(selectedAddress, shouldHideZeroBalanceTokens);

tokensWithBalances.forEach((token) => {
// token.string is the balance displayed in the TokenList UI
token.string = roundToDecimalPlacesRemovingExtraZeroes(token.string, 5);
});
const balanceIsZero = Number(totalFiatBalance) === 0;
const isBuyableChain = useSelector(getIsBuyableChain);
const shouldShowBuy = isBuyableChain && balanceIsZero;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ exports[`Token Cell should match snapshot 1`] = `
style="flex-grow: 1; overflow: hidden;"
>
<div
class="mm-box mm-box--display-flex mm-box--gap-1 mm-box--justify-content-space-between"
class="mm-box mm-box--display-flex mm-box--gap-1 mm-box--flex-direction-row mm-box--justify-content-space-between"
>
<div
class="mm-box mm-box--display-inline-block mm-box--width-1/3"
Expand All @@ -61,15 +61,34 @@ exports[`Token Cell should match snapshot 1`] = `
5.00
</p>
</div>
<p
class="mm-box mm-text mm-text--body-md mm-box--color-text-alternative"
data-testid="multichain-token-list-item-value"
<div
class="mm-box mm-box--display-flex mm-box--gap-1 mm-box--flex-direction-row mm-box--justify-content-space-between"
>
5.000

TEST

</p>
<div
class="mm-box mm-box--width-1/3"
>
<p
class="mm-box mm-text mm-text--body-md mm-text--font-weight-medium mm-text--ellipsis mm-box--color-text-alternative"
data-testid="multichain-token-list-item-token-name"
>
TEST
</p>
</div>
<div
class="mm-box mm-box--width-2/3"
style="overflow: hidden;"
>
<p
class="mm-box mm-text mm-text--body-md mm-text--font-weight-medium mm-text--text-align-end mm-box--color-text-alternative"
data-testid="multichain-token-list-item-value"
>
5.000

TEST

</p>
</div>
</div>
</div>
</a>
</div>
Expand Down
4 changes: 2 additions & 2 deletions ui/components/app/token-cell/token-cell.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ describe('Token Cell', () => {
});

it('should render the correct token and filter by symbol and address', () => {
const { queryByText, getByAltText } = renderWithProvider(
const { getByTestId, getByAltText } = renderWithProvider(
<TokenCell {...props} />,
mockStore,
);

const image = getByAltText('TEST logo');

expect(queryByText('TEST')).toBeInTheDocument();
expect(getByTestId('multichain-token-list-item-value')).toBeInTheDocument();
expect(image).toBeInTheDocument();
expect(image).toHaveAttribute('src', './images/test_image.svg');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ exports[`TokenListItem should render correctly 1`] = `
style="flex-grow: 1; overflow: hidden;"
>
<div
class="mm-box mm-box--display-flex mm-box--gap-1 mm-box--justify-content-space-between"
class="mm-box mm-box--display-flex mm-box--gap-1 mm-box--flex-direction-row mm-box--justify-content-space-between"
>
<div
class="mm-box mm-box--display-inline-block mm-box--width-1/3"
Expand All @@ -52,13 +52,30 @@ exports[`TokenListItem should render correctly 1`] = `
data-testid="multichain-token-list-item-secondary-value"
/>
</div>
<p
class="mm-box mm-text mm-text--body-md mm-box--color-text-alternative"
data-testid="multichain-token-list-item-value"
<div
class="mm-box mm-box--display-flex mm-box--gap-1 mm-box--flex-direction-row mm-box--justify-content-space-between"
>


</p>
<div
class="mm-box mm-box--width-1/3"
>
<p
class="mm-box mm-text mm-text--body-md mm-text--font-weight-medium mm-text--ellipsis mm-box--color-text-alternative"
data-testid="multichain-token-list-item-token-name"
/>
</div>
<div
class="mm-box mm-box--width-2/3"
style="overflow: hidden;"
>
<p
class="mm-box mm-text mm-text--body-md mm-text--font-weight-medium mm-text--text-align-end mm-box--color-text-alternative"
data-testid="multichain-token-list-item-value"
>


</p>
</div>
</div>
</div>
</a>
</div>
Expand Down
44 changes: 35 additions & 9 deletions ui/components/multichain/token-list-item/token-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export const TokenListItem = ({
>
<Box
display={Display.Flex}
flexDirection={FlexDirection.Row}
justifyContent={JustifyContent.spaceBetween}
gap={1}
>
Expand All @@ -222,10 +223,10 @@ export const TokenListItem = ({
>
{isStakeable ? (
<>
{tokenTitle} {stakeableTitle}
{tokenSymbol} {stakeableTitle}
</>
) : (
tokenTitle
tokenSymbol
)}
</Text>
</Tooltip>
Expand All @@ -238,10 +239,10 @@ export const TokenListItem = ({
>
{isStakeable ? (
<Box display={Display.InlineBlock}>
{tokenTitle} {stakeableTitle}
{tokenSymbol} {stakeableTitle}
</Box>
) : (
tokenTitle
tokenSymbol
)}
</Text>
)}
Expand Down Expand Up @@ -271,12 +272,37 @@ export const TokenListItem = ({
</Text>
)}
</Box>
<Text
color={TextColor.textAlternative}
data-testid="multichain-token-list-item-value"
<Box
display={Display.Flex}
flexDirection={FlexDirection.Row}
justifyContent={JustifyContent.spaceBetween}
gap={1}
>
{primary} {tokenSymbol}{' '}
</Text>
<Box width={BlockSize.OneThird}>
{/* bottom left */}
<Text
fontWeight={FontWeight.Medium}
variant={TextVariant.bodyMd}
color={TextColor.textAlternative}
data-testid="multichain-token-list-item-token-name" //
ellipsis
>
{tokenTitle}
</Text>
</Box>
<Box style={{ overflow: 'hidden' }} width={BlockSize.TwoThirds}>
{/* bottom right */}
<Text
data-testid="multichain-token-list-item-value"
color={TextColor.textAlternative}
fontWeight={FontWeight.Medium}
variant={TextVariant.bodyMd}
textAlign={TextAlign.End}
>
{primary} {tokenSymbol}{' '}
</Text>
</Box>
</Box>
</Box>
</Box>
{showScamWarningModal ? (
Expand Down
Loading