Browse Source

Integrate Pills on Dashboard

master
meriadec 7 years ago
parent
commit
370cf3b7d7
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 50
      src/components/DashboardPage.js

50
src/components/DashboardPage.js

@ -18,10 +18,9 @@ import { formatBTC } from 'helpers/format'
import { getTotalBalance, getVisibleAccounts } from 'reducers/accounts' import { getTotalBalance, getVisibleAccounts } from 'reducers/accounts'
import Box, { Card } from 'components/base/Box' import Box, { Card } from 'components/base/Box'
import Pills from 'components/base/Pills'
import Text from 'components/base/Text' import Text from 'components/base/Text'
import { AreaChart, BarChart } from 'components/base/Chart' import { AreaChart, BarChart } from 'components/base/Chart'
import Select from 'components/base/Select'
import Tabs from 'components/base/Tabs'
const mapStateToProps: MapStateToProps<*, *, *> = state => ({ const mapStateToProps: MapStateToProps<*, *, *> = state => ({
accounts: getVisibleAccounts(state), accounts: getVisibleAccounts(state),
@ -39,17 +38,18 @@ type Props = {
} }
type State = { type State = {
tab: number,
fakeDatas: Array<any>, fakeDatas: Array<any>,
selectedTime: string,
} }
const ACCOUNTS_BY_LINE = 3 const ACCOUNTS_BY_LINE = 3
const TIMEOUT_REFRESH_DATAS = 5e3 const TIMEOUT_REFRESH_DATAS = 5e3
const itemsTimes = [ const itemsTimes = [
{ key: 'week', name: 'Last week' }, { key: 'day', label: 'Day' },
{ key: 'month', name: 'Last month' }, { key: 'week', label: 'Week' },
{ key: 'year', name: 'Last year' }, { key: 'month', label: 'Month' },
{ key: 'year', label: 'Year' },
] ]
const generateFakeData = v => ({ const generateFakeData = v => ({
@ -59,7 +59,7 @@ const generateFakeData = v => ({
class DashboardPage extends PureComponent<Props, State> { class DashboardPage extends PureComponent<Props, State> {
state = { state = {
tab: 0, selectedTime: 'day',
fakeDatas: this.generateFakeDatas(), fakeDatas: this.generateFakeDatas(),
} }
@ -107,13 +107,11 @@ class DashboardPage extends PureComponent<Props, State> {
}, TIMEOUT_REFRESH_DATAS) }, TIMEOUT_REFRESH_DATAS)
} }
handleChangeTab = tab => this.setState({ tab })
_timeout = undefined _timeout = undefined
render() { render() {
const { totalBalance, push, accounts } = this.props const { totalBalance, push, accounts } = this.props
const { tab, fakeDatas } = this.state const { selectedTime, fakeDatas } = this.state
const totalAccounts = accounts.length const totalAccounts = accounts.length
@ -131,39 +129,17 @@ class DashboardPage extends PureComponent<Props, State> {
</Text> </Text>
</Box> </Box>
<Box ml="auto"> <Box ml="auto">
<Select <Pills
items={itemsTimes} items={itemsTimes}
value={itemsTimes[0]} activeKey={selectedTime}
renderSelected={item => item.name} onChange={item => this.setState({ selectedTime: item.key })}
style={{ width: 250 }}
/> />
</Box> </Box>
</Box> </Box>
<Card flow={3}>
<Tabs
index={tab}
onTabClick={this.handleChangeTab}
items={[
{
key: 'balance',
title: 'Total balance',
render: () => (
<Box>
<Text fontSize={4}>{formatBTC(totalBalance)}</Text>
</Box>
),
},
{
key: 'market',
title: 'Market',
render: () => <Box>{'Not yet. Be patient.'}</Box>,
},
]}
/>
</Card>
{totalAccounts > 0 && ( {totalAccounts > 0 && (
<Fragment> <Fragment>
<Card flow={3} p={0}> <Card flow={3} p={4}>
<Text>{formatBTC(totalBalance)}</Text>
<AreaChart <AreaChart
height={250} height={250}
data={takeRight( data={takeRight(

Loading…
Cancel
Save