From 843cc87c5efe98b37b4adc7b65bcd6072a7ef714 Mon Sep 17 00:00:00 2001 From: Ana G <40721795+Bitcoinera@users.noreply.github.com> Date: Sat, 18 Jan 2020 15:43:33 +0100 Subject: [PATCH] Ana/better multiple denoms porfolio version (#3434) * pyramid state * add scroll. scroll bar not showing * Update src/components/common/TmBalance.vue * switch ids for classes * Update TmBalance.vue * fixed tests * changelog Co-authored-by: Fabian --- ...na_better-multiple-denoms-porfolio-version | 1 + src/components/common/TmBalance.vue | 115 +++++++++++++----- .../specs/components/common/TmBalance.spec.js | 2 +- .../__snapshots__/TmBalance.spec.js.snap | 62 ++++++---- 4 files changed, 124 insertions(+), 56 deletions(-) create mode 100644 changes/ana_better-multiple-denoms-porfolio-version diff --git a/changes/ana_better-multiple-denoms-porfolio-version b/changes/ana_better-multiple-denoms-porfolio-version new file mode 100644 index 0000000000..8cd833b0ef --- /dev/null +++ b/changes/ana_better-multiple-denoms-porfolio-version @@ -0,0 +1 @@ +[Added] Show multiple wallet balances in UI @faboweb \ No newline at end of file diff --git a/src/components/common/TmBalance.vue b/src/components/common/TmBalance.vue index c9726929e6..c380e468ef 100644 --- a/src/components/common/TmBalance.vue +++ b/src/components/common/TmBalance.vue @@ -20,6 +20,7 @@ -
-
-

Total Tokens

-

- -

-
-
-
-
-

Available {{ stakingDenom }}

-

{{ overview.liquidStake | shortDecimals | noBlanks }}

-
+
+
+
+

Available {{ stakingDenom }}

+

{{ overview.liquidStake | shortDecimals | noBlanks }}

+
-
-

Total Rewards

-

+{{ overview.totalRewards | shortDecimals | noBlanks }}

+
+

Total Rewards

+

+{{ overview.totalRewards | shortDecimals | noBlanks }}

+
+
+
+
+

{{ balance.denom }}

+

{{ balance.amount }}

+
@@ -124,6 +123,20 @@ export default { readyToWithdraw() { return this.overview.totalRewards > 0 }, + formattedBalances() { + return this.balances + .filter(balance => !balance.denom.includes(this.stakingDenom)) + .map( + balance => + (balance = { + denom: balance.denom + .charAt(0) + .toLowerCase() + .concat(balance.denom.slice(-3)), + amount: parseFloat(balance.amount).toFixed(2) + }) + ) + }, concatBalances() { let balancesArray = [] if (this.balances.length > 1) { @@ -154,7 +167,7 @@ export default { ] }, getAllDenoms() { - if (this.balances) { + if (this.balances.length > 0) { const balances = this.balances return balances.map(({ denom }) => denom) } else { @@ -232,7 +245,7 @@ export default { }, /* istanbul ignore next */ update(data) { - return data.balances + return data.balances || [] } }, stakingDenom: { @@ -318,6 +331,25 @@ export default { padding-right: 2.5rem; } +.tokens-div { + position: absolute; + right: 1.25rem; + top: 3.5rem; +} + +.tokens-div > .col { + margin-right: 1rem; +} + +.token-denom { + font-size: 12px; + float: left; +} + +.token-balance { + font-weight: bold; +} + .currency-selector.tm-form-group { position: absolute; right: 1.25rem; @@ -384,6 +416,33 @@ export default { text-align: center; } + .scroll { + display: flex; + width: 90vw; + overflow-x: auto; + /* Make it smooth scrolling on iOS devices */ + -webkit-overflow-scrolling: touch; + } + + /* This doesn't work */ + /* .scroll > .scroll-item { + flex: 0 0 auto; + } */ + + .scroll > .row > div { + margin-right: 3rem; + } + + .tokens-div { + position: inherit; + margin: 0; + top: 0; + } + + .token-denom { + float: none; + } + .currency-selector.tm-form-group { width: 40px; right: 2.5rem; diff --git a/tests/unit/specs/components/common/TmBalance.spec.js b/tests/unit/specs/components/common/TmBalance.spec.js index fd82da2026..d2c5492b80 100644 --- a/tests/unit/specs/components/common/TmBalance.spec.js +++ b/tests/unit/specs/components/common/TmBalance.spec.js @@ -110,7 +110,7 @@ describe(`TmBalance`, () => { it(`if no balances are found, then it returns the staking denom`, () => { wrapper.setData({ - balances: `` + balances: [] }) expect(wrapper.vm.getAllDenoms).toEqual(["ATOM"]) }) diff --git a/tests/unit/specs/components/common/__snapshots__/TmBalance.spec.js.snap b/tests/unit/specs/components/common/__snapshots__/TmBalance.spec.js.snap index 510d0bd93e..090c5a8d35 100644 --- a/tests/unit/specs/components/common/__snapshots__/TmBalance.spec.js.snap +++ b/tests/unit/specs/components/common/__snapshots__/TmBalance.spec.js.snap @@ -30,12 +30,16 @@ exports[`TmBalance do not show available atoms when the user has none in the fir
- -
- +
+ + + +
@@ -59,7 +63,7 @@ exports[`TmBalance do not show available atoms when the user has none in the fir @@ -97,34 +101,38 @@ exports[`TmBalance show the balance header when signed in 1`] = ` - -
-

- Available ATOM -

+
+

+ Available ATOM +

+ +

+ 1,230 +

+
-

- 1,230 -

+
+

+ Total Rewards +

+ +

+ +1,000.45 +

+
-
-

- Total Rewards -

- -

- +1,000.45 -

-
+
@@ -145,7 +153,7 @@ exports[`TmBalance show the balance header when signed in 1`] = `