1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Show token symbol when token amount string is long (#9333)

* Show token symbol when token amount string is long

Fixes #9318

This essentially separates the token cell list item title/token amount and the token symbol.
I do request advice/recomendations on how to better handle the new `subTtitle` which I set the token symbol to and the `subtitle` https://github.com/MetaMask/metamask-extension/blob/develop/ui/app/components/app/asset-list-item/asset-list-item.js#L99.

* Individually test token balance and token symbol and their associated css element

* Feedback commit

* Classname and css overflow for title with string.
This commit is contained in:
Thomas Huang 2020-09-01 13:13:58 -07:00 committed by GitHub
parent 72313f011d
commit a3f9e6d37b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 16 deletions

View File

@ -94,7 +94,12 @@ const AssetListItem = ({
<ListItem
className={classnames('asset-list-item', className)}
data-testid={dataTestId}
title={primary}
title={(
<>
<h2 className="asset-list-item__token-value">{primary}</h2>
<h2 className="asset-list-item__token-symbol">{tokenSymbol}</h2>
</>
)}
titleIcon={titleIcon}
subtitle={<h3 title={secondary}>{secondary}</h3>}
onClick={onClick}

View File

@ -1,4 +1,11 @@
.asset-list-item {
&__token-value {
padding: 0 5px 0 0;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
&__chevron-right {
color: $Grey-500;
}

View File

@ -47,7 +47,7 @@ export default function TokenCell ({
tokenSymbol={symbol}
tokenDecimals={decimals}
warning={warning}
primary={`${string || 0} ${symbol}`}
primary={`${string || 0}`}
secondary={formattedFiat}
/>

View File

@ -68,8 +68,12 @@ describe('Token Cell', function () {
assert.equal(wrapper.find(Identicon).prop('image'), './test-image')
})
it('renders token balance and symbol', function () {
assert.equal(wrapper.find('.list-item__heading').text(), '5.000 TEST')
it('renders token balance', function () {
assert.equal(wrapper.find('.asset-list-item__token-value').text(), '5.000')
})
it('renders token symbol', function () {
assert.equal(wrapper.find('.asset-list-item__token-symbol').text(), 'TEST')
})
it('renders converted fiat amount', function () {

View File

@ -44,18 +44,18 @@
display: flex;
align-items: center;
> h2 {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
&-wrap {
display: inline-block;
margin-left: 8px;
}
}
&__title {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
&__subheading {
grid-area: sub;
font-size: 12px;

View File

@ -23,8 +23,8 @@ export default function ListItem ({
{icon}
</div>
)}
<div className="list-item__heading" title={title}>
<h2>{ title }</h2>
<div className="list-item__heading">
{React.isValidElement(title) ? title : <h2 className="list-item__title">{ title }</h2>}
{titleIcon && (
<div className="list-item__heading-wrap">
{titleIcon}
@ -56,7 +56,7 @@ export default function ListItem ({
}
ListItem.propTypes = {
title: PropTypes.string.isRequired,
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
titleIcon: PropTypes.node,
subtitle: PropTypes.node,
children: PropTypes.node,

View File

@ -40,9 +40,6 @@ describe('ListItem', function () {
it(`renders "${TITLE}" title`, function () {
assert.equal(wrapper.find('.list-item__heading h2').text(), TITLE)
})
it('adds html title to heading element', function () {
assert.equal(wrapper.find('.list-item__heading').props().title, TITLE)
})
it(`renders "I am a list item" subtitle`, function () {
assert.equal(wrapper.find('.list-item__subheading').text(), 'I am a list item')
})