From 2d1fa52638b3669e76278654764615cfe68376e3 Mon Sep 17 00:00:00 2001 From: meriadec Date: Mon, 12 Feb 2018 13:46:13 +0100 Subject: [PATCH 1/2] Create and use BoldToggle component --- src/components/base/BoldToggle.js | 38 ++++++++++++++++++++++++++++++ src/components/base/Pills/index.js | 14 +++++++---- 2 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 src/components/base/BoldToggle.js diff --git a/src/components/base/BoldToggle.js b/src/components/base/BoldToggle.js new file mode 100644 index 00000000..08850d40 --- /dev/null +++ b/src/components/base/BoldToggle.js @@ -0,0 +1,38 @@ +// @flow + +import React from 'react' + +import Text from 'components/base/Text' +import Box from 'components/base/Box' + +type Props = { + boldWeight?: string | number, + normalWeight?: string | number, + isBold: boolean, + children: any, +} + +function BoldToggle(props: Props) { + const { boldWeight, normalWeight, isBold, children, ...p } = props + return ( + + + {children} + + {!isBold && ( + + + {children} + + + )} + + ) +} + +BoldToggle.defaultProps = { + boldWeight: 600, + normalWeight: 400, +} + +export default BoldToggle diff --git a/src/components/base/Pills/index.js b/src/components/base/Pills/index.js index 5c2c7ec4..4e0039eb 100644 --- a/src/components/base/Pills/index.js +++ b/src/components/base/Pills/index.js @@ -5,6 +5,7 @@ import styled from 'styled-components' import { rgba } from 'styles/helpers' import Box, { Tabbable } from 'components/base/Box' +import BoldToggle from 'components/base/BoldToggle' type Item = { key: string, @@ -43,11 +44,14 @@ function Pills(props: Props) { const { items, activeKey, onChange, ...p } = props return ( - {items.map(item => ( - onChange(item)} key={item.key}> - {item.label} - - ))} + {items.map(item => { + const isActive = item.key === activeKey + return ( + onChange(item)} key={item.key}> + {item.label} + + ) + })} ) } From 507c02d6e0b6e2b3b13a652de634ae2ffbb23e8b Mon Sep 17 00:00:00 2001 From: meriadec Date: Mon, 12 Feb 2018 14:55:25 +0100 Subject: [PATCH 2/2] New TopBar --- src/components/GlobalSearch.js | 41 ++++++++++++++++++++ src/components/TopBar.js | 65 +++++++++++++++++++++++--------- src/components/Wrapper.js | 2 +- src/components/base/Box/index.js | 4 +- src/styles/theme.js | 6 ++- 5 files changed, 97 insertions(+), 21 deletions(-) create mode 100644 src/components/GlobalSearch.js diff --git a/src/components/GlobalSearch.js b/src/components/GlobalSearch.js new file mode 100644 index 00000000..361c5d4b --- /dev/null +++ b/src/components/GlobalSearch.js @@ -0,0 +1,41 @@ +// @flow + +import React, { PureComponent } from 'react' +import styled from 'styled-components' + +import Box from 'components/base/Box' +import Icon from 'components/base/Icon' + +const Input = styled.input` + border: none; + background: transparent; + outline: none; + flex-grow: 1; + + &::placeholder { + color: ${p => p.theme.colors.warmGrey}; + } +` + +class GlobalSearch extends PureComponent { + _input = null + + focusInput = () => { + if (this._input) { + this._input.focus() + } + } + + render() { + return ( + + + + + (this._input = input)} /> + + ) + } +} + +export default GlobalSearch diff --git a/src/components/TopBar.js b/src/components/TopBar.js index ac9a6c6f..414f1493 100644 --- a/src/components/TopBar.js +++ b/src/components/TopBar.js @@ -7,20 +7,17 @@ import { ipcRenderer } from 'electron' import type { MapStateToProps, MapDispatchToProps } from 'react-redux' +import { rgba } from 'styles/helpers' import { getAccounts } from 'reducers/accounts' import { lock } from 'reducers/application' import { hasPassword } from 'reducers/settings' import Box from 'components/base/Box' +import GlobalSearch from 'components/GlobalSearch' +import Icon from 'components/base/Icon' const Container = styled(Box).attrs({ - borderColor: 'argile', - borderWidth: 1, - borderBottom: true, - noShrink: true, - px: 3, - align: 'center', - horizontal: true, + px: 5, })` height: 60px; position: absolute; @@ -31,6 +28,20 @@ const Container = styled(Box).attrs({ z-index: 20; ` +const Inner = styled(Box).attrs({ + horizontal: true, + grow: true, + borderBottom: true, + borderWidth: 1, + borderColor: p => rgba(p.theme.colors.black, 0.15), +})`` + +const Bar = styled.div` + height: 15px; + width: 1px; + background: ${p => p.theme.colors.warmGrey}; +` + const mapStateToProps: MapStateToProps<*, *, *> = state => ({ hasAccounts: getAccounts(state).length > 0, hasPassword: hasPassword(state), @@ -45,6 +56,7 @@ type Props = { hasPassword: boolean, lock: Function, } + type State = { sync: { progress: null | boolean, @@ -104,16 +116,35 @@ class TopBar extends PureComponent { const { sync } = this.state return ( - - - {hasAccounts && - (sync.progress === true - ? 'Synchronizing...' - : sync.fail === true ? 'Synchronization fail :(' : 'Synchronisation finished!')} - - - {hasPassword && } - + + + + + + + + + + + + + + + {hasAccounts && + (sync.progress === true + ? 'Synchronizing...' + : sync.fail === true ? 'Synchronization fail :(' : 'Synchronisation finished!')} + + + {hasPassword && } + + + + + {'Khalil Benihoud'} + + + ) } diff --git a/src/components/Wrapper.js b/src/components/Wrapper.js index 7bc3e3ad..25fdba0e 100644 --- a/src/components/Wrapper.js +++ b/src/components/Wrapper.js @@ -50,7 +50,7 @@ class Wrapper extends Component<{}> { - + diff --git a/src/components/base/Box/index.js b/src/components/base/Box/index.js index e0ff082a..2a3601ff 100644 --- a/src/components/base/Box/index.js +++ b/src/components/base/Box/index.js @@ -16,10 +16,10 @@ import { import Text from 'components/base/Text' -const spacingScale = [0, 8, 16, 32, 64] +import { space as spaceScale } from 'styles/theme' function getSpace(n) { - return `${spacingScale[n] || n}px` + return `${spaceScale[n] || n}px` } const Box = styled.div` diff --git a/src/styles/theme.js b/src/styles/theme.js index 1a882ca6..c6143812 100644 --- a/src/styles/theme.js +++ b/src/styles/theme.js @@ -1,10 +1,14 @@ // @flow +export const space = [0, 5, 10, 15, 20, 30, 40, 50, 70] +export const fontSizes = [8, 9, 10, 11, 13, 16, 18, 32] + export default { sizes: { sideBarWidth: 250, }, - fontSizes: [13, 14, 16, 20, 24, 32, 48, 64, 72], + space, + fontSizes, colors: { transparent: 'transparent',