Browse Source

Use DropDown for Lock App, fix issue fix accounts db

master
Loëck Vézien 7 years ago
parent
commit
2b2a213ab2
No known key found for this signature in database GPG Key ID: CBCDCE384E853AC4
  1. 21
      src/components/DashboardPage/AccountCard.js
  2. 53
      src/components/DashboardPage/index.js
  3. 38
      src/components/TopBar.js
  4. 25
      src/components/base/DropDown/index.js
  5. 1
      src/main/app.js
  6. 6
      src/renderer/init.js

21
src/components/DashboardPage/AccountCard.js

@ -9,6 +9,7 @@ import IconCurrencyBitcoin from 'icons/currencies/Bitcoin'
import { AreaChart } from 'components/base/Chart' import { AreaChart } from 'components/base/Chart'
import Bar from 'components/base/Bar' import Bar from 'components/base/Bar'
import Box, { Card } from 'components/base/Box' import Box, { Card } from 'components/base/Box'
import Defer from 'components/base/Defer'
import FormattedVal from 'components/base/FormattedVal' import FormattedVal from 'components/base/FormattedVal'
const AccountCard = ({ const AccountCard = ({
@ -46,15 +47,17 @@ const AccountCard = ({
/> />
)} )}
</Box> </Box>
<AreaChart <Defer>
tiny <AreaChart
id={`account-chart-${account.id}`} tiny
color="#fcb653" id={`account-chart-${account.id}`}
height={52} color="#fcb653"
data={data} height={52}
strokeWidth={1} data={data}
linearGradient={[[5, 0.4], [80, 0]]} strokeWidth={1}
/> linearGradient={[[5, 0.4], [80, 0]]}
/>
</Defer>
</Card> </Card>
) )

53
src/components/DashboardPage/index.js

@ -25,6 +25,7 @@ import { saveSettings } from 'actions/settings'
import { AreaChart } from 'components/base/Chart' import { AreaChart } from 'components/base/Chart'
import Box, { Card } from 'components/base/Box' import Box, { Card } from 'components/base/Box'
import Pills from 'components/base/Pills' import Pills from 'components/base/Pills'
import Defer from 'components/base/Defer'
import Text from 'components/base/Text' import Text from 'components/base/Text'
import TransactionsList from 'components/TransactionsList' import TransactionsList from 'components/TransactionsList'
@ -185,31 +186,33 @@ class DashboardPage extends PureComponent<Props, State> {
<Box px={6}> <Box px={6}>
<BalanceInfos since={selectedTime} /> <BalanceInfos since={selectedTime} />
</Box> </Box>
<Box ff="Open Sans" fontSize={4} color="warmGrey"> <Defer>
<AreaChart <Box ff="Open Sans" fontSize={4} color="warmGrey">
id="dashboard-chart" <AreaChart
margin={{ id="dashboard-chart"
top: space[6], margin={{
bottom: 0, top: space[6],
left: space[6] - 10, bottom: 0,
right: space[6], left: space[6] - 10,
}} right: space[6],
color="#5286f7" }}
height={250} color="#5286f7"
data={takeRight( height={250}
fakeDatas.reduce((res, data) => { data={takeRight(
data.forEach((d, i) => { fakeDatas.reduce((res, data) => {
res[i] = { data.forEach((d, i) => {
name: d.name, res[i] = {
value: (res[i] ? res[i].value : 0) + d.value, name: d.name,
} value: (res[i] ? res[i].value : 0) + d.value,
}) }
return res })
}, []), return res
25, }, []),
)} 25,
/> )}
</Box> />
</Box>
</Defer>
</Card> </Card>
<Box flow={4}> <Box flow={4}>
<Box horizontal align="flex-end"> <Box horizontal align="flex-end">

38
src/components/TopBar.js

@ -35,6 +35,7 @@ const Inner = styled(Box).attrs({
horizontal: true, horizontal: true,
grow: true, grow: true,
borderBottom: true, borderBottom: true,
flow: 4,
borderWidth: 1, borderWidth: 1,
borderColor: p => rgba(p.theme.colors.black, 0.15), borderColor: p => rgba(p.theme.colors.black, 0.15),
})`` })``
@ -146,15 +147,17 @@ class TopBar extends PureComponent<Props, State> {
<Box justify="center"> <Box justify="center">
<Bar /> <Bar />
</Box> </Box>
<Box justify="flex-end" horizontal>
{hasPassword && <LockApplication onLock={this.handleLock} />}
</Box>
</Box> </Box>
<Box horizontal noShrink> <Box horizontal noShrink>
<DropDown <DropDown
items={[{ key: 'empty', label: 'Nothing here yet' }]} items={
hasPassword
? [{ key: 'lock', label: 'Lock application', onClick: this.handleLock }]
: []
}
ff="Open Sans|SemiBold" ff="Open Sans|SemiBold"
fontSize={4} fontSize={4}
offsetTop={-2}
> >
<Box horizontal align="center" flow={1} color="warmGrey"> <Box horizontal align="center" flow={1} color="warmGrey">
<Box>{'Khalil Benihoud'}</Box> <Box>{'Khalil Benihoud'}</Box>
@ -168,31 +171,4 @@ class TopBar extends PureComponent<Props, State> {
} }
} }
const LockApplication = ({ onLock }: { onLock: Function }) => (
<Box
relative
color="night"
mr={20}
horizontal
flow={10}
onClick={onLock}
style={{ cursor: 'pointer' }}
>
<LockIcon height={20} width={20} />
</Box>
)
const LockIcon = props => (
<svg {...props} viewBox="0 0 482.8 482.8">
<path
d="M395.95 210.4h-7.1v-62.9c0-81.3-66.1-147.5-147.5-147.5-81.3 0-147.5 66.1-147.5 147.5 0 7.5 6 13.5 13.5 13.5s13.5-6 13.5-13.5c0-66.4 54-120.5 120.5-120.5 66.4 0 120.5 54 120.5 120.5v62.9h-275c-14.4 0-26.1 11.7-26.1 26.1v168.1c0 43.1 35.1 78.2 78.2 78.2h204.9c43.1 0 78.2-35.1 78.2-78.2V236.5c0-14.4-11.7-26.1-26.1-26.1zm-.9 194.2c0 28.2-22.9 51.2-51.2 51.2h-204.8c-28.2 0-51.2-22.9-51.2-51.2V237.4h307.2v167.2z"
fill="currentColor"
/>
<path
d="M241.45 399.1c27.9 0 50.5-22.7 50.5-50.5 0-27.9-22.7-50.5-50.5-50.5-27.9 0-50.5 22.7-50.5 50.5s22.6 50.5 50.5 50.5zm0-74.1c13 0 23.5 10.6 23.5 23.5s-10.5 23.6-23.5 23.6-23.5-10.6-23.5-23.5 10.5-23.6 23.5-23.6z"
fill="currentColor"
/>
</svg>
)
export default connect(mapStateToProps, mapDispatchToProps)(TopBar) export default connect(mapStateToProps, mapDispatchToProps)(TopBar)

25
src/components/base/DropDown/index.js

@ -14,6 +14,7 @@ type ItemType = {
type Props = { type Props = {
children: any, children: any,
offsetTop: number | string,
items: Array<ItemType>, items: Array<ItemType>,
value?: ItemType | null, value?: ItemType | null,
onChange?: ItemType => void, onChange?: ItemType => void,
@ -28,7 +29,6 @@ const Drop = styled(Box).attrs({
bg: 'white', bg: 'white',
boxShadow: 0, boxShadow: 0,
borderRadius: 1, borderRadius: 1,
mt: 1,
})` })`
position: absolute; position: absolute;
top: 100%; top: 100%;
@ -45,6 +45,7 @@ const Item = styled(Box).attrs({
px: 4, px: 4,
bg: p => (p.isHighlighted ? 'pearl' : ''), bg: p => (p.isHighlighted ? 'pearl' : ''),
})` })`
cursor: pointer;
white-space: nowrap; white-space: nowrap;
` `
@ -56,18 +57,28 @@ class DropDown extends PureComponent<Props> {
static defaultProps = { static defaultProps = {
value: null, value: null,
onChange: noop, onChange: noop,
offsetTop: 1,
} }
renderItems = (items: Array<ItemType>, selectedItem: ItemType, downshiftProps: Object) => { renderItems = (items: Array<ItemType>, selectedItem: ItemType, downshiftProps: Object) => {
const { offsetTop } = this.props
const { getItemProps, highlightedIndex } = downshiftProps const { getItemProps, highlightedIndex } = downshiftProps
return ( return (
<Drop> <Drop mt={offsetTop}>
{items.map((item, i) => ( {items.map((item, i) => {
<Item isHighlighted={highlightedIndex === i} key={item.key} {...getItemProps({ item })}> const { key, label, ...props } = item
{item.label} return (
</Item> <Item
))} isHighlighted={highlightedIndex === i}
key={item.key}
{...getItemProps({ item })}
{...props}
>
{item.label}
</Item>
)
})}
</Drop> </Drop>
) )
} }

1
src/main/app.js

@ -186,6 +186,7 @@ function createPreloadWindow() {
alwaysOnTop: true, alwaysOnTop: true,
closable: false, closable: false,
fullscreenable: false, fullscreenable: false,
resizable: false,
} }
const window = new BrowserWindow(windowOptions) const window = new BrowserWindow(windowOptions)

6
src/renderer/init.js

@ -20,8 +20,7 @@ import App from 'components/App'
import 'styles/global' import 'styles/global'
// init db with defaults if needed // Init settings with defaults if needed
db.init('accounts', [])
db.init('settings', {}) db.init('settings', {})
const history = createHistory() const history = createHistory()
@ -35,6 +34,9 @@ const language = getLanguage(state)
const locked = isLocked(state) const locked = isLocked(state)
if (!locked) { if (!locked) {
// Init accounts with defaults if needed
db.init('accounts', [])
store.dispatch(fetchAccounts()) store.dispatch(fetchAccounts())
} }

Loading…
Cancel
Save