diff --git a/src/components/DashboardPage/AccountCard.js b/src/components/DashboardPage/AccountCard.js new file mode 100644 index 00000000..1a788663 --- /dev/null +++ b/src/components/DashboardPage/AccountCard.js @@ -0,0 +1,53 @@ +// @flow + +import React from 'react' + +import type { Account } from 'types/common' + +import { formatBTC } from 'helpers/format' + +import { AreaChart } from 'components/base/Chart' +import Bar from 'components/base/Bar' +import Box, { Card } from 'components/base/Box' +import Icon from 'components/base/Icon' + +const AccountCard = ({ + account, + data, + onClick, +}: { + account: Account, + data: Array, + onClick: Function, +}) => ( + + + + + + + + {account.type} + + + {account.name} + + + + + + {account.data && formatBTC(account.data.balance)} + + + +) + +export default AccountCard diff --git a/src/components/DashboardPage/index.js b/src/components/DashboardPage/index.js index 9396446a..bdafe16d 100644 --- a/src/components/DashboardPage/index.js +++ b/src/components/DashboardPage/index.js @@ -17,10 +17,12 @@ import { formatBTC } from 'helpers/format' import { getTotalBalance, getVisibleAccounts } from 'reducers/accounts' +import { AreaChart } from 'components/base/Chart' import Box, { Card } from 'components/base/Box' import Pills from 'components/base/Pills' import Text from 'components/base/Text' -import { AreaChart, BarChart } from 'components/base/Chart' + +import AccountCard from './AccountCard' const mapStateToProps: MapStateToProps<*, *, *> = state => ({ accounts: getVisibleAccounts(state), @@ -138,23 +140,27 @@ class DashboardPage extends PureComponent { {totalAccounts > 0 && ( - + {formatBTC(totalBalance)} - { - data.forEach((d, i) => { - res[i] = { - name: d.name, - value: (res[i] ? res[i].value : 0) + d.value, - } - }) - return res - }, []), - 25, - )} - /> + + { + data.forEach((d, i) => { + res[i] = { + name: d.name, + value: (res[i] ? res[i].value : 0) + d.value, + } + }) + return res + }, []), + 25, + )} + /> + {this.getAccountsChunk().map((accountsByLine, i) => ( @@ -172,21 +178,12 @@ class DashboardPage extends PureComponent { flex={1} /> ) : ( - push(`/account/${account.id}`)} - > - - {account.name} - - - {account.data && formatBTC(account.data.balance)} - - - + /> ), )} diff --git a/src/components/base/Box/index.js b/src/components/base/Box/index.js index 1aa4cb48..cbde0e91 100644 --- a/src/components/base/Box/index.js +++ b/src/components/base/Box/index.js @@ -7,6 +7,7 @@ import { borderColor, borderRadius, borderWidth, + boxShadow, color, flex, fontSize, @@ -23,6 +24,7 @@ const Box = styled.div` ${borderColor}; ${borderRadius}; ${borderWidth}; + ${boxShadow}; ${color}; ${flex}; ${fontFamily}; @@ -53,10 +55,7 @@ const Box = styled.div` } ` -const RawCard = styled(Box).attrs({ bg: 'white', p: 3 })` - box-shadow: rgba(0, 0, 0, 0.06) 0 8px 30px; - border-radius: 5px; -` +const RawCard = styled(Box).attrs({ bg: 'white', p: 3, boxShadow: 0, borderRadius: 1 })`` export const Card = ({ title, ...props }: { title?: string }) => { if (title) { diff --git a/src/components/base/Chart/index.js b/src/components/base/Chart/index.js index 958f016a..9971f14a 100644 --- a/src/components/base/Chart/index.js +++ b/src/components/base/Chart/index.js @@ -1,15 +1,7 @@ // @flow import React, { PureComponent } from 'react' -import { - AreaChart as ReactAreaChart, - BarChart as ReactBarChart, - Bar, - Area, - XAxis, - CartesianGrid, - Tooltip, -} from 'recharts' +import { AreaChart as ReactAreaChart, Area, XAxis, CartesianGrid, Tooltip } from 'recharts' import Box from 'components/base/Box' @@ -72,68 +64,79 @@ class Container extends PureComponent { } } -export const AreaChart = ({ height, data }: { height: number, data: Array }) => ( +export const AreaChart = ({ + id, + linearGradient, + strokeWidth, + height, + color, + data, + margin, + tiny, +}: { + id: string, + linearGradient?: Array>, + strokeWidth?: number, + height: number, + color: string, + data: Array, + margin?: Object, + tiny?: boolean, +}) => ( ( - - - - - - - - { - const { value } = payload - - if (index !== 0 && index !== visibleTicksCount - 1) { - return ( - - - {value} - - - ) - } - - return null - }} - /> - - + render={({ width, isAnimationActive }) => ( + + {linearGradient && ( + + + {linearGradient.map(g => ( + + ))} + + + )} + {!tiny && ( + { + const { value } = payload + + if (index !== 0 && index !== visibleTicksCount - 1) { + return ( + + + {value} + + + ) + } + + return null + }} + /> + )} + {!tiny && } + {!tiny && } )} /> ) -export const BarChart = ({ height, data }: { height: number, data: Array }) => ( - ( - - - - )} - /> -) +AreaChart.defaultProps = { + linearGradient: [[5, 0.3], [65, 0]], + margin: undefined, + strokeWidth: 2, + tiny: false, +} diff --git a/src/components/base/Icon/index.js b/src/components/base/Icon/index.js index 12af7f54..48b5ce8b 100644 --- a/src/components/base/Icon/index.js +++ b/src/components/base/Icon/index.js @@ -12,7 +12,7 @@ const Container = styled.span` position: relative; ` -export default ({ name, ...props }: { name: string }) => ( +export default ({ name, ...props }: { name: string | Object }) => ( diff --git a/src/styles/theme.js b/src/styles/theme.js index f22c3727..f5f89857 100644 --- a/src/styles/theme.js +++ b/src/styles/theme.js @@ -3,6 +3,7 @@ export const space = [0, 5, 10, 15, 20, 30, 40, 50, 70] export const fontSizes = [8, 9, 10, 11, 13, 16, 18, 22, 32] export const radii = [0, 4] +export const shadows = ['0 4px 8px 0 rgba(0, 0, 0, 0.03)'] export const fontFamilies = { 'Open Sans': { @@ -60,6 +61,7 @@ export default { fontFamilies, fontSizes, space, + shadows, colors: { transparent: 'transparent',