Merge pull request #4575 from whymarrh/token-amount-overflow

Handle token amount overflows
This commit is contained in:
Whymarrh Whitby 2018-06-20 16:34:44 -02:30 committed by GitHub
commit 41a48195ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 35 additions and 16 deletions

View File

@ -348,8 +348,9 @@ describe('Using MetaMask with an existing account', function () {
it('renders the balance for the new token', async () => { it('renders the balance for the new token', async () => {
const balance = await findElement(driver, By.css('.tx-view .balance-display .token-amount')) const balance = await findElement(driver, By.css('.tx-view .balance-display .token-amount'))
await driver.wait(until.elementTextMatches(balance, /^0\s*BAT\s*$/), 10000)
const tokenAmount = await balance.getText() const tokenAmount = await balance.getText()
assert.equal(tokenAmount, '0BAT') assert.ok(/^0\s*BAT\s*$/.test(tokenAmount))
await delay(regularDelayMs) await delay(regularDelayMs)
}) })
}) })
@ -421,9 +422,9 @@ describe('Using MetaMask with an existing account', function () {
it('renders the balance for the new token', async () => { it('renders the balance for the new token', async () => {
const balance = await findElement(driver, By.css('.tx-view .balance-display .token-amount')) const balance = await findElement(driver, By.css('.tx-view .balance-display .token-amount'))
await driver.wait(until.elementTextIs(balance, '100TST')) await driver.wait(until.elementTextMatches(balance, /^100\s*TST\s*$/), 10000)
const tokenAmount = await balance.getText() const tokenAmount = await balance.getText()
assert.equal(tokenAmount, '100TST') assert.ok(/^100\s*TST\s*$/.test(tokenAmount))
await delay(regularDelayMs) await delay(regularDelayMs)
}) })
}) })

View File

@ -430,9 +430,9 @@ describe('MetaMask', function () {
it('renders the balance for the chosen token', async () => { it('renders the balance for the chosen token', async () => {
const balance = await findElement(driver, By.css('.tx-view .balance-display .token-amount')) const balance = await findElement(driver, By.css('.tx-view .balance-display .token-amount'))
await driver.wait(until.elementTextIs(balance, '0BAT')) await driver.wait(until.elementTextMatches(balance, /^0\s*BAT\s*$/), 10000)
const tokenAmount = await balance.getText() const tokenAmount = await balance.getText()
assert.equal(tokenAmount, '0BAT') assert.ok(/^0\s*BAT\s*$/.test(tokenAmount))
await delay(regularDelayMs) await delay(regularDelayMs)
}) })
}) })
@ -504,9 +504,9 @@ describe('MetaMask', function () {
it('renders the balance for the new token', async () => { it('renders the balance for the new token', async () => {
const balance = await findElement(driver, By.css('.tx-view .balance-display .token-amount')) const balance = await findElement(driver, By.css('.tx-view .balance-display .token-amount'))
await driver.wait(until.elementTextIs(balance, '100TST')) await driver.wait(until.elementTextMatches(balance, /^100\s*TST\s*$/))
const tokenAmount = await balance.getText() const tokenAmount = await balance.getText()
assert.equal(tokenAmount, '100TST') assert.ok(/^100\s*TST\s*$/.test(tokenAmount))
await delay(regularDelayMs) await delay(regularDelayMs)
}) })
}) })

View File

@ -36,6 +36,7 @@ IdenticonComponent.prototype.render = function () {
key: 'identicon-' + address, key: 'identicon-' + address,
style: { style: {
display: 'flex', display: 'flex',
flexShrink: 0,
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
height: diameter, height: diameter,

View File

@ -149,7 +149,7 @@ CurrencyDisplay.prototype.render = function () {
} : {}), } : {}),
ref: input => { this.currencyInput = input }, ref: input => { this.currencyInput = input },
style: { style: {
width: this.getInputWidth(valueToRender, readOnly), minWidth: this.getInputWidth(valueToRender, readOnly),
}, },
min: 0, min: 0,
}), }),

View File

@ -34,7 +34,7 @@ TokenBalance.prototype.render = function () {
return isLoading return isLoading
? h('span', '') ? h('span', '')
: h('span.token-balance', [ : h('span.token-balance', [
h('span.token-balance__amount', string), h('span.hide-text-overflow.token-balance__amount', string),
!balanceOnly && h('span.token-balance__symbol', symbol), !balanceOnly && h('span.token-balance__symbol', symbol),
]) ])
} }

View File

@ -1,6 +1,5 @@
.currency-display { .currency-display {
height: 54px; height: 54px;
width: 100%ß;
border: 1px solid $alto; border: 1px solid $alto;
border-radius: 4px; border-radius: 4px;
background-color: $white; background-color: $white;
@ -21,7 +20,7 @@
line-height: 22px; line-height: 22px;
border: none; border: none;
outline: 0 !important; outline: 0 !important;
max-width: 100%; max-width: 22ch;
} }
&__primary-currency { &__primary-currency {
@ -47,6 +46,9 @@
&__input-wrapper { &__input-wrapper {
position: relative; position: relative;
display: flex; display: flex;
flex: 1;
max-width: 100%;
overflow-x: scroll;
input[type="number"]::-webkit-inner-spin-button { input[type="number"]::-webkit-inner-spin-button {
-webkit-appearance: none; -webkit-appearance: none;
@ -75,4 +77,4 @@
display: none; display: none;
} }
} }
} }

View File

@ -27,25 +27,37 @@
@media screen and (max-width: $break-small) { @media screen and (max-width: $break-small) {
flex-direction: column; flex-direction: column;
flex: 0 0 auto; flex: 0 0 auto;
max-width: 100%;
} }
@media screen and (min-width: $break-large) { @media screen and (min-width: $break-large) {
flex-direction: row; flex-direction: row;
flex-grow: 3; flex-grow: 3;
min-width: 0;
} }
} }
.balance-display { .balance-display {
.token-amount { .token-amount {
color: $black; color: $black;
max-width: 100%;
.token-balance {
display: flex;
}
} }
@media screen and (max-width: $break-small) { @media screen and (max-width: $break-small) {
max-width: 100%;
text-align: center; text-align: center;
.token-amount { .token-amount {
font-size: 1.75rem; font-size: 1.75rem;
margin-top: 1rem; margin-top: 1rem;
.token-balance {
flex-direction: column;
}
} }
.fiat-amount { .fiat-amount {
@ -56,9 +68,10 @@
} }
@media screen and (min-width: $break-large) { @media screen and (min-width: $break-large) {
margin-left: .8em; margin: 0 .8em;
justify-content: flex-start; justify-content: flex-start;
align-items: flex-start; align-items: flex-start;
min-width: 0;
.token-amount { .token-amount {
font-size: 1.5rem; font-size: 1.5rem;

View File

@ -26,14 +26,16 @@ $wallet-view-bg: $alabaster;
//Account and transaction details //Account and transaction details
.account-and-transaction-details { .account-and-transaction-details {
display: flex; display: flex;
flex: 1 0 auto; flex: 1 1 auto;
min-width: 0;
} }
// tx view // tx view
.tx-view { .tx-view {
flex: 63.5 0 66.5%; flex: 1 1 66.5%;
background: $tx-view-bg; background: $tx-view-bg;
min-width: 0;
// No title on mobile // No title on mobile
@media screen and (max-width: 575px) { @media screen and (max-width: 575px) {
@ -286,7 +288,7 @@ $wallet-view-bg: $alabaster;
} }
.token-balance__amount { .token-balance__amount {
padding-right: 6px; padding: 0 6px;
} }
// first time // first time