From 24915b72318cd07fac11bcc47bb2fa859b2b89a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Tue, 31 Jul 2018 08:36:10 +0200 Subject: [PATCH] Split AccountCard as well --- src/components/DashboardPage/AccountCard.js | 103 ------------------ .../DashboardPage/AccountCard/Header.js | 33 ++++++ .../DashboardPage/AccountCard/index.js | 94 ++++++++++++++++ 3 files changed, 127 insertions(+), 103 deletions(-) delete mode 100644 src/components/DashboardPage/AccountCard.js create mode 100644 src/components/DashboardPage/AccountCard/Header.js create mode 100644 src/components/DashboardPage/AccountCard/index.js diff --git a/src/components/DashboardPage/AccountCard.js b/src/components/DashboardPage/AccountCard.js deleted file mode 100644 index a9881a2f..00000000 --- a/src/components/DashboardPage/AccountCard.js +++ /dev/null @@ -1,103 +0,0 @@ -// @flow - -import React, { PureComponent } from 'react' -import styled from 'styled-components' - -import type { Account, Currency } from '@ledgerhq/live-common/lib/types' - -import Chart from 'components/base/Chart' -import Bar from 'components/base/Bar' -import Box, { Card } from 'components/base/Box' -import CalculateBalance from 'components/CalculateBalance' -import FormattedVal from 'components/base/FormattedVal' -import Ellipsis from 'components/base/Ellipsis' -import CryptoCurrencyIcon from 'components/CryptoCurrencyIcon' -import DeltaChange from '../DeltaChange' - -const Wrapper = styled(Card).attrs({ - p: 4, - flex: 1, -})` - cursor: ${p => (p.onClick ? 'pointer' : 'default')}; -` - -class AccountCard extends PureComponent<{ - counterValue: Currency, - account: Account, - onClick?: Account => void, - daysCount: number, -}> { - render() { - const { counterValue, account, onClick, daysCount, ...props } = this.props - return ( - onClick(account) : null} {...props}> - - - - - - - - {account.currency.name} - - - {account.name} - - - - - - - - - - {({ isAvailable, balanceHistory, balanceStart, balanceEnd }) => ( - - - - {isAvailable ? ( - - ) : null} - - - {isAvailable && !balanceStart.isZero() ? ( - - ) : null} - - - - - )} - - - ) - } -} - -export default AccountCard diff --git a/src/components/DashboardPage/AccountCard/Header.js b/src/components/DashboardPage/AccountCard/Header.js new file mode 100644 index 00000000..642ec56e --- /dev/null +++ b/src/components/DashboardPage/AccountCard/Header.js @@ -0,0 +1,33 @@ +// @flow + +import React, { PureComponent } from 'react' +import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types' +import Box from 'components/base/Box' +import Ellipsis from 'components/base/Ellipsis' +import CryptoCurrencyIcon from 'components/CryptoCurrencyIcon' + +class AccountCardHeader extends PureComponent<{ + currency: CryptoCurrency, + accountName: string, +}> { + render() { + const { currency, accountName } = this.props + return ( + + + + + + + {currency.name} + + + {accountName} + + + + ) + } +} + +export default AccountCardHeader diff --git a/src/components/DashboardPage/AccountCard/index.js b/src/components/DashboardPage/AccountCard/index.js new file mode 100644 index 00000000..25dc16d4 --- /dev/null +++ b/src/components/DashboardPage/AccountCard/index.js @@ -0,0 +1,94 @@ +// @flow + +import React, { PureComponent } from 'react' +import styled from 'styled-components' + +import type { Account, Currency } from '@ledgerhq/live-common/lib/types' + +import Chart from 'components/base/Chart' +import Bar from 'components/base/Bar' +import Box, { Card } from 'components/base/Box' +import CalculateBalance from 'components/CalculateBalance' +import FormattedVal from 'components/base/FormattedVal' +import DeltaChange from 'components/DeltaChange' +import AccountCardHeader from './Header' + +const Wrapper = styled(Card).attrs({ + p: 4, + flex: 1, +})` + cursor: ${p => (p.onClick ? 'pointer' : 'default')}; +` + +class AccountCard extends PureComponent<{ + counterValue: Currency, + account: Account, + onClick: Account => void, + daysCount: number, +}> { + renderBody = ({ isAvailable, balanceHistory, balanceStart, balanceEnd }: *) => { + const { counterValue, account } = this.props + return ( + + + + {isAvailable ? ( + + ) : null} + + + {isAvailable && !balanceStart.isZero() ? ( + + ) : null} + + + + + ) + } + onClick = () => { + const { account, onClick } = this.props + onClick(account) + } + render() { + const { counterValue, account, onClick, daysCount, ...props } = this.props + return ( + + + + + + + + + + {this.renderBody} + + + ) + } +} + +export default AccountCard