diff --git a/src/components/DashboardPage/BalanceInfos.js b/src/components/DashboardPage/BalanceInfos.js new file mode 100644 index 00000000..44886ecd --- /dev/null +++ b/src/components/DashboardPage/BalanceInfos.js @@ -0,0 +1,57 @@ +// @flow + +import React from 'react' +import { connect } from 'react-redux' +import styled from 'styled-components' + +import type { MapStateToProps } from 'react-redux' + +import { getTotalBalance } from 'reducers/accounts' + +import Box from 'components/base/Box' +import Text from 'components/base/Text' +import FormattedVal from 'components/base/FormattedVal' + +const mapStateToProps: MapStateToProps<*, *, *> = state => ({ + totalBalance: getTotalBalance(state), +}) + +type Props = { + totalBalance: number, +} + +const Sub = styled(Text).attrs({ + ff: 'Open Sans', + color: 'warmGrey', + fontSize: 4, +})`` + +function BalanceInfos(props: Props) { + const { totalBalance } = props + return ( + + + + {'Total balance'} + + + + {'since one week'} + + + + {'since one week'} + + + ) +} + +export default connect(mapStateToProps)(BalanceInfos) diff --git a/src/components/DashboardPage/index.js b/src/components/DashboardPage/index.js index bd9dc575..0c09381d 100644 --- a/src/components/DashboardPage/index.js +++ b/src/components/DashboardPage/index.js @@ -13,10 +13,9 @@ import takeRight from 'lodash/takeRight' import type { MapStateToProps } from 'react-redux' import type { Accounts } from 'types/common' -import { formatBTC } from 'helpers/format' import { space } from 'styles/theme' -import { getTotalBalance, getVisibleAccounts } from 'reducers/accounts' +import { getVisibleAccounts } from 'reducers/accounts' import { AreaChart } from 'components/base/Chart' import Box, { Card } from 'components/base/Box' @@ -24,10 +23,10 @@ import Pills from 'components/base/Pills' import Text from 'components/base/Text' import AccountCard from './AccountCard' +import BalanceInfos from './BalanceInfos' const mapStateToProps: MapStateToProps<*, *, *> = state => ({ accounts: getVisibleAccounts(state), - totalBalance: getTotalBalance(state), }) const mapDispatchToProps = { @@ -37,7 +36,6 @@ const mapDispatchToProps = { type Props = { accounts: Accounts, push: Function, - totalBalance: number, } type State = { @@ -113,7 +111,7 @@ class DashboardPage extends PureComponent { _timeout = undefined render() { - const { totalBalance, push, accounts } = this.props + const { push, accounts } = this.props const { selectedTime, fakeDatas } = this.state const totalAccounts = accounts.length @@ -142,7 +140,9 @@ class DashboardPage extends PureComponent { {totalAccounts > 0 && ( - {formatBTC(totalBalance)} + + + p.theme.sizes.sideBarWidth}px; ` -const Connected = styled(Box).attrs({ - bg: p => (p.state ? 'green' : 'grenade'), - mx: 3, -})` - border-radius: 50%; - height: 10px; - width: 10px; -` - const PlusBtn = styled(Tabbable).attrs({ p: 1, m: -1, @@ -72,12 +61,10 @@ type Props = { t: T, accounts: Accounts, openModal: Function, - currentDevice: Device, } const mapStateToProps: MapStateToProps<*, *, *> = state => ({ accounts: getVisibleAccounts(state), - currentDevice: getCurrentDevice(state), }) const mapDispatchToProps = { @@ -86,7 +73,7 @@ const mapDispatchToProps = { class SideBar extends PureComponent { render() { - const { t, accounts, openModal, currentDevice } = this.props + const { t, accounts, openModal } = this.props return ( @@ -131,21 +118,6 @@ class SideBar extends PureComponent { - - - - - - - Ledger Nano S - - - - {t(currentDevice !== null ? 'device.connected' : 'device.notConnected')} - - - - ) } diff --git a/src/components/TopBar.js b/src/components/TopBar.js index a6dc5cfa..c8169d0a 100644 --- a/src/components/TopBar.js +++ b/src/components/TopBar.js @@ -41,7 +41,7 @@ const Inner = styled(Box).attrs({ const Bar = styled.div` height: 15px; width: 1px; - background: ${p => p.theme.colors.warmGrey}; + background: ${p => p.theme.colors.mouse}; ` const mapStateToProps: MapStateToProps<*, *, *> = state => ({ diff --git a/src/components/base/FormattedVal.js b/src/components/base/FormattedVal.js new file mode 100644 index 00000000..6e468dfd --- /dev/null +++ b/src/components/base/FormattedVal.js @@ -0,0 +1,72 @@ +// @flow + +import React from 'react' +import styled from 'styled-components' + +import { formatCurrencyUnit } from '@ledgerhq/currencies' + +import Text from 'components/base/Text' + +const T = styled(Text).attrs({ + ff: 'Rubik', + color: p => (p.isNegative ? p.theme.colors.grenade : p.theme.colors.green), +})`` + +const currencies = { + BTC: { + name: 'bitcoin', + code: 'BTC', + symbol: 'b', + magnitude: 8, + }, + USD: { + name: 'dollar', + code: 'USD', + symbol: '$', + magnitude: 0, + }, +} + +type Props = { + val: number, + isPercent?: boolean, + currency?: any, + alwaysShowSign?: boolean, + showCode?: boolean, +} + +function FormattedVal(props: Props) { + const { val, isPercent, currency, alwaysShowSign, showCode, ...p } = props + + const isNegative = val < 0 + + let text = '' + + if (isPercent) { + text = `${alwaysShowSign ? (isNegative ? '- ' : '+ ') : ''}${val} %` + } else { + const curr = currency ? currencies[currency] : null + if (!curr) { + return `[invalid currency ${currency || '(null)'}]` + } + text = formatCurrencyUnit(curr, val, { + alwaysShowSign, + showCode, + }) + } + + return ( + + {text} + + ) +} + +FormattedVal.defaultProps = { + currency: null, + isPercent: false, + alwaysShowSign: false, + showCode: false, +} + +export default FormattedVal diff --git a/src/styles/global.js b/src/styles/global.js index c2ee932d..ab25b0a6 100644 --- a/src/styles/global.js +++ b/src/styles/global.js @@ -65,6 +65,13 @@ const fonts = { file: 'museosans/MuseoSans-ExtraBold', }, ], + Rubik: [ + { + style: 'normal', + weight: 500, + file: 'rubik/Rubik-Regular', + }, + ], } function transformFonts(allFonts) { diff --git a/src/styles/theme.js b/src/styles/theme.js index f5f89857..55a30dfa 100644 --- a/src/styles/theme.js +++ b/src/styles/theme.js @@ -51,6 +51,13 @@ export const fontFamilies = { style: 'normal', }, }, + + Rubik: { + Regular: { + weight: 500, + style: 'normal', + }, + }, } export default { diff --git a/static/fonts/rubik/Rubik-Regular.woff2 b/static/fonts/rubik/Rubik-Regular.woff2 new file mode 100644 index 00000000..a4fc17b4 Binary files /dev/null and b/static/fonts/rubik/Rubik-Regular.woff2 differ