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:
parent
72313f011d
commit
a3f9e6d37b
@ -94,7 +94,12 @@ const AssetListItem = ({
|
|||||||
<ListItem
|
<ListItem
|
||||||
className={classnames('asset-list-item', className)}
|
className={classnames('asset-list-item', className)}
|
||||||
data-testid={dataTestId}
|
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}
|
titleIcon={titleIcon}
|
||||||
subtitle={<h3 title={secondary}>{secondary}</h3>}
|
subtitle={<h3 title={secondary}>{secondary}</h3>}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
.asset-list-item {
|
.asset-list-item {
|
||||||
|
&__token-value {
|
||||||
|
padding: 0 5px 0 0;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
&__chevron-right {
|
&__chevron-right {
|
||||||
color: $Grey-500;
|
color: $Grey-500;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ export default function TokenCell ({
|
|||||||
tokenSymbol={symbol}
|
tokenSymbol={symbol}
|
||||||
tokenDecimals={decimals}
|
tokenDecimals={decimals}
|
||||||
warning={warning}
|
warning={warning}
|
||||||
primary={`${string || 0} ${symbol}`}
|
primary={`${string || 0}`}
|
||||||
secondary={formattedFiat}
|
secondary={formattedFiat}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
@ -68,8 +68,12 @@ describe('Token Cell', function () {
|
|||||||
assert.equal(wrapper.find(Identicon).prop('image'), './test-image')
|
assert.equal(wrapper.find(Identicon).prop('image'), './test-image')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders token balance and symbol', function () {
|
it('renders token balance', function () {
|
||||||
assert.equal(wrapper.find('.list-item__heading').text(), '5.000 TEST')
|
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 () {
|
it('renders converted fiat amount', function () {
|
||||||
|
@ -44,18 +44,18 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
> h2 {
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-wrap {
|
&-wrap {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
&__subheading {
|
&__subheading {
|
||||||
grid-area: sub;
|
grid-area: sub;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
@ -23,8 +23,8 @@ export default function ListItem ({
|
|||||||
{icon}
|
{icon}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="list-item__heading" title={title}>
|
<div className="list-item__heading">
|
||||||
<h2>{ title }</h2>
|
{React.isValidElement(title) ? title : <h2 className="list-item__title">{ title }</h2>}
|
||||||
{titleIcon && (
|
{titleIcon && (
|
||||||
<div className="list-item__heading-wrap">
|
<div className="list-item__heading-wrap">
|
||||||
{titleIcon}
|
{titleIcon}
|
||||||
@ -56,7 +56,7 @@ export default function ListItem ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
ListItem.propTypes = {
|
ListItem.propTypes = {
|
||||||
title: PropTypes.string.isRequired,
|
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
||||||
titleIcon: PropTypes.node,
|
titleIcon: PropTypes.node,
|
||||||
subtitle: PropTypes.node,
|
subtitle: PropTypes.node,
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
|
@ -40,9 +40,6 @@ describe('ListItem', function () {
|
|||||||
it(`renders "${TITLE}" title`, function () {
|
it(`renders "${TITLE}" title`, function () {
|
||||||
assert.equal(wrapper.find('.list-item__heading h2').text(), TITLE)
|
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 () {
|
it(`renders "I am a list item" subtitle`, function () {
|
||||||
assert.equal(wrapper.find('.list-item__subheading').text(), 'I am a list item')
|
assert.equal(wrapper.find('.list-item__subheading').text(), 'I am a list item')
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user