Skip to content

Commit

Permalink
WIP - Accounts tab design
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBenc committed Nov 27, 2020
1 parent 92ceaa6 commit 1eaf3ed
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 19 deletions.
109 changes: 96 additions & 13 deletions 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}) => (
<div className="card" style={'width: 100%;'}>
<h2 className="card-title small-margin" />
<div className="account-dropdown">
{range(0, 5).map((i) => (
<a
key={i}
const Account = ({i, account, setAccount, selectedAccount, toggleDisplayStakingPage}) => {
return (
<div key={i} className="card account" style={'width: 75%;'}>
<div className="card-column" style="align-self: center;">
<button
className="button primary"
disabled={false} //{selectedAccount === i}
onClick={() => {
setAccount(i)
toggleDisplayStakingPage('Sending')
window.scrollTo({top: 0, behavior: 'smooth'})
}}
>
Account {i}
</a>
))}
</button>
</div>
<div className="card-column">
<h2 className="card-title small-margin">Available balance</h2>
<div className="balance-amount small">
{printAda(
account
? account.shelleyBalances.stakingBalance + account.shelleyBalances.nonStakingBalance
: 0
)}
<AdaIcon />
</div>
</div>
<div className="card-column">
<h2 className="card-title small-margin">Rewards balance</h2>
<div className="balance-amount small">
{printAda(account ? account.shelleyBalances.rewardsAccountBalance : 0)}
<AdaIcon />
</div>
</div>
<div className="card-column">
<h2 className="card-title small-margin">Delegation</h2>
<div>
{account
? account.shelleyAccountInfo.delegation.name || UNKNOWN_POOL_NAME
: 'Not delegated'}
</div>
</div>
</div>
</div>
)
)
}

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 (
<Fragment>
<div className="dashboard-column account">
<div className="card account" style={'width: 100%;'}>
<div>
<h2 className="card-title small-margin">Total balance</h2>
<div className="balance-amount">
{printAda(totalBalance as Lovelace)}
<AdaIcon />
</div>
</div>
<div>
<h2 className="card-title small-margin">Total rewards balance</h2>
<div className="balance-amount">
{printAda(totalRewardBalance as Lovelace)}
<AdaIcon />
</div>
</div>
</div>
<div className="dashboard-column account wide">
<div>
{range(0, Object.keys(accounts).length + 1).map((i) => (
<Account
key={i}
i={i}
account={accounts[i]}
setAccount={setAccount}
selectedAccount={selectedAccount}
toggleDisplayStakingPage={toggleDisplayStakingPage}
/>
))}
</div>
<div className="dashboard-column account narrow"> </div>
</div>
</div>
</Fragment>
)
}

export default connect(
(state) => ({
isDemoWallet: state.isDemoWallet,
router: state.router,
accounts: state.accounts,
selectedAccount: state.selectedAccount,
}),
actions
)(Accounts)
8 changes: 2 additions & 6 deletions app/frontend/components/pages/dashboard/dashboardPage.tsx
Expand Up @@ -70,11 +70,7 @@ const AdvancedPage = () => {
}

const AccountsPage = () => {
return (
<Fragment>
<Accounts />
</Fragment>
)
return <Accounts />
}

class DashboardPage extends Component<Props> {
Expand Down Expand Up @@ -132,7 +128,7 @@ class DashboardPage extends Component<Props> {
<MainTab
key={i}
name={name}
selectedTab={selectedMainTab}
selectedTab={displayStakingPage}
selectTab={this.selectMainTab}
/>
))}
Expand Down
33 changes: 33 additions & 0 deletions app/public/css/styles.css
Expand Up @@ -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%;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -1426,6 +1445,10 @@ li.main-tab input + label.selected:after {
margin-bottom: 12px;
}

.card.account {
display: flex;
}

/* AUTHENTICATION */

.authentication {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 1eaf3ed

Please sign in to comment.