From 2b2a213ab27f92a76e47f5564b0f1a29ea7bae3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=ABck=20V=C3=A9zien?= Date: Wed, 14 Feb 2018 17:40:32 +0100 Subject: [PATCH] Use DropDown for Lock App, fix issue fix accounts db --- src/components/DashboardPage/AccountCard.js | 21 ++++---- src/components/DashboardPage/index.js | 53 +++++++++++---------- src/components/TopBar.js | 38 +++------------ src/components/base/DropDown/index.js | 25 +++++++--- src/main/app.js | 1 + src/renderer/init.js | 6 ++- 6 files changed, 70 insertions(+), 74 deletions(-) diff --git a/src/components/DashboardPage/AccountCard.js b/src/components/DashboardPage/AccountCard.js index b2670992..5837847b 100644 --- a/src/components/DashboardPage/AccountCard.js +++ b/src/components/DashboardPage/AccountCard.js @@ -9,6 +9,7 @@ import IconCurrencyBitcoin from 'icons/currencies/Bitcoin' import { AreaChart } from 'components/base/Chart' import Bar from 'components/base/Bar' import Box, { Card } from 'components/base/Box' +import Defer from 'components/base/Defer' import FormattedVal from 'components/base/FormattedVal' const AccountCard = ({ @@ -46,15 +47,17 @@ const AccountCard = ({ /> )} - + + + ) diff --git a/src/components/DashboardPage/index.js b/src/components/DashboardPage/index.js index 3e4dedfe..dda36a6c 100644 --- a/src/components/DashboardPage/index.js +++ b/src/components/DashboardPage/index.js @@ -25,6 +25,7 @@ import { saveSettings } from 'actions/settings' import { AreaChart } from 'components/base/Chart' import Box, { Card } from 'components/base/Box' import Pills from 'components/base/Pills' +import Defer from 'components/base/Defer' import Text from 'components/base/Text' import TransactionsList from 'components/TransactionsList' @@ -185,31 +186,33 @@ class DashboardPage extends PureComponent { - - { - 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, + )} + /> + + diff --git a/src/components/TopBar.js b/src/components/TopBar.js index 136ee881..24ca53e2 100644 --- a/src/components/TopBar.js +++ b/src/components/TopBar.js @@ -35,6 +35,7 @@ const Inner = styled(Box).attrs({ horizontal: true, grow: true, borderBottom: true, + flow: 4, borderWidth: 1, borderColor: p => rgba(p.theme.colors.black, 0.15), })`` @@ -146,15 +147,17 @@ class TopBar extends PureComponent { - - {hasPassword && } - {'Khalil Benihoud'} @@ -168,31 +171,4 @@ class TopBar extends PureComponent { } } -const LockApplication = ({ onLock }: { onLock: Function }) => ( - - - -) - -const LockIcon = props => ( - - - - -) - export default connect(mapStateToProps, mapDispatchToProps)(TopBar) diff --git a/src/components/base/DropDown/index.js b/src/components/base/DropDown/index.js index b07dd485..f6608038 100644 --- a/src/components/base/DropDown/index.js +++ b/src/components/base/DropDown/index.js @@ -14,6 +14,7 @@ type ItemType = { type Props = { children: any, + offsetTop: number | string, items: Array, value?: ItemType | null, onChange?: ItemType => void, @@ -28,7 +29,6 @@ const Drop = styled(Box).attrs({ bg: 'white', boxShadow: 0, borderRadius: 1, - mt: 1, })` position: absolute; top: 100%; @@ -45,6 +45,7 @@ const Item = styled(Box).attrs({ px: 4, bg: p => (p.isHighlighted ? 'pearl' : ''), })` + cursor: pointer; white-space: nowrap; ` @@ -56,18 +57,28 @@ class DropDown extends PureComponent { static defaultProps = { value: null, onChange: noop, + offsetTop: 1, } renderItems = (items: Array, selectedItem: ItemType, downshiftProps: Object) => { + const { offsetTop } = this.props const { getItemProps, highlightedIndex } = downshiftProps return ( - - {items.map((item, i) => ( - - {item.label} - - ))} + + {items.map((item, i) => { + const { key, label, ...props } = item + return ( + + {item.label} + + ) + })} ) } diff --git a/src/main/app.js b/src/main/app.js index 6820f6e3..0b3ab971 100644 --- a/src/main/app.js +++ b/src/main/app.js @@ -186,6 +186,7 @@ function createPreloadWindow() { alwaysOnTop: true, closable: false, fullscreenable: false, + resizable: false, } const window = new BrowserWindow(windowOptions) diff --git a/src/renderer/init.js b/src/renderer/init.js index 4f469b06..080c6eae 100644 --- a/src/renderer/init.js +++ b/src/renderer/init.js @@ -20,8 +20,7 @@ import App from 'components/App' import 'styles/global' -// init db with defaults if needed -db.init('accounts', []) +// Init settings with defaults if needed db.init('settings', {}) const history = createHistory() @@ -35,6 +34,9 @@ const language = getLanguage(state) const locked = isLocked(state) if (!locked) { + // Init accounts with defaults if needed + db.init('accounts', []) + store.dispatch(fetchAccounts()) }