From 1eaf3edf3145298fca7c671cc2526b4eb71f386c Mon Sep 17 00:00:00 2001 From: Peter Benc Date: Thu, 26 Nov 2020 17:52:40 +0100 Subject: [PATCH] WIP - Accounts tab design --- .../components/pages/accounts/accounts.tsx | 109 +++++++++++++++--- .../pages/dashboard/dashboardPage.tsx | 8 +- app/public/css/styles.css | 33 ++++++ 3 files changed, 131 insertions(+), 19 deletions(-) diff --git a/app/frontend/components/pages/accounts/accounts.tsx b/app/frontend/components/pages/accounts/accounts.tsx index 92d6d34f41..fede59a313 100644 --- a/app/frontend/components/pages/accounts/accounts.tsx +++ b/app/frontend/components/pages/accounts/accounts.tsx @@ -1,30 +1,113 @@ -import {h} from 'preact' +import {Fragment, h} from 'preact' import {connect} from '../../../helpers/connect' import actions from '../../../actions' import range from '../../../../frontend/wallet/helpers/range' +import printAda from '../../../helpers/printAda' +import {Lovelace} from '../../../state' +import {AdaIcon} from '../../common/svg' +import {UNKNOWN_POOL_NAME} from '../../../../frontend/wallet/constants' -const Accounts = ({setAccount}) => ( -
-

-
- {range(0, 5).map((i) => ( - { + return ( +
+ +
+

Available balance

+
+ {printAda( + account + ? account.shelleyBalances.stakingBalance + account.shelleyBalances.nonStakingBalance + : 0 + )} + +
+
+
+

Rewards balance

+
+ {printAda(account ? account.shelleyBalances.rewardsAccountBalance : 0)} + +
+
+
+

Delegation

+
+ {account + ? account.shelleyAccountInfo.delegation.name || UNKNOWN_POOL_NAME + : 'Not delegated'} +
+
-
-) + ) +} + +const Accounts = ({accounts, setAccount, selectedAccount, toggleDisplayStakingPage}) => { + const accountInfos = Object.values(accounts) + const totalBalance = accountInfos.reduce( + (a, {shelleyBalances}) => + shelleyBalances.stakingBalance + shelleyBalances.nonStakingBalance + a, + 0 + ) + const totalRewardBalance = accountInfos.reduce( + (a, {shelleyBalances}) => shelleyBalances.rewardsAccountBalance + a, + 0 + ) + return ( + +
+
+
+

Total balance

+
+ {printAda(totalBalance as Lovelace)} + +
+
+
+

Total rewards balance

+
+ {printAda(totalRewardBalance as Lovelace)} + +
+
+
+
+
+ {range(0, Object.keys(accounts).length + 1).map((i) => ( + + ))} +
+
+
+
+
+ ) +} export default connect( (state) => ({ isDemoWallet: state.isDemoWallet, - router: state.router, + accounts: state.accounts, + selectedAccount: state.selectedAccount, }), actions )(Accounts) diff --git a/app/frontend/components/pages/dashboard/dashboardPage.tsx b/app/frontend/components/pages/dashboard/dashboardPage.tsx index 79dbdc006b..a0da5cc16c 100644 --- a/app/frontend/components/pages/dashboard/dashboardPage.tsx +++ b/app/frontend/components/pages/dashboard/dashboardPage.tsx @@ -70,11 +70,7 @@ const AdvancedPage = () => { } const AccountsPage = () => { - return ( - - - - ) + return } class DashboardPage extends Component { @@ -132,7 +128,7 @@ class DashboardPage extends Component { ))} diff --git a/app/public/css/styles.css b/app/public/css/styles.css index 97f6969860..136a6e87d1 100644 --- a/app/public/css/styles.css +++ b/app/public/css/styles.css @@ -1262,6 +1262,14 @@ button[data-balloon] { display: none; } +.dashboard-column.wide { + flex: 1 1 75%; +} + +.dashboard-column.narrow { + flex: 1 1 25%; +} + .dashboard-column { flex: 1 1 50%; } @@ -1274,6 +1282,11 @@ button[data-balloon] { padding-left: 28px; } +.dashboard-column.account { + padding-left: 0px; + padding-right: 0px; +} + .dashboard-column .card:not(:last-child) { margin-bottom: 56px; } @@ -1407,6 +1420,12 @@ li.main-tab input + label.selected:after { box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.08); } +.card-column { + padding-left: 8px; + flex-grow: 1; + flex-basis: 25%; +} + .card-title { margin-bottom: 24px; font-size: 16px; @@ -1426,6 +1445,10 @@ li.main-tab input + label.selected:after { margin-bottom: 12px; } +.card.account { + display: flex; +} + /* AUTHENTICATION */ .authentication { @@ -2175,11 +2198,21 @@ li.main-tab input + label.selected:after { position: relative; } +.balance-amount.small { + font-size: 24px; +} + .balance-amount svg { margin-left: 12px; width: 18px; +} + +.balance-amount.small svg { + margin-left: 12px; + width: 14px; } + .balance-amount svg path { fill: var(--color-brand); }