From ce40e3d96f6b716adf6fd968f14f5c02aeb0e57d Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 25 Jan 2018 09:26:21 +0100 Subject: [PATCH 1/8] Add side margin to modals by default and minor styles updates --- src/components/SideBar/index.js | 2 +- src/components/base/Modal/index.js | 15 +++++++++------ src/components/base/Modal/stories.js | 2 ++ src/styles/theme.js | 3 +++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/components/SideBar/index.js b/src/components/SideBar/index.js index 07da6439..df8e832b 100644 --- a/src/components/SideBar/index.js +++ b/src/components/SideBar/index.js @@ -30,7 +30,7 @@ const Container = styled(Box).attrs({ noShrink: true, })` background-color: ${p => rgba(p.theme.colors[p.bg], process.platform === 'darwin' ? 0.4 : 1)}; - width: 250px; + width: ${p => p.theme.sizes.sideBarWidth}px; ` const BtnAddAccount = styled(Box).attrs({ diff --git a/src/components/base/Modal/index.js b/src/components/base/Modal/index.js index a368900e..a201acd9 100644 --- a/src/components/base/Modal/index.js +++ b/src/components/base/Modal/index.js @@ -20,7 +20,8 @@ import Box from 'components/base/Box' type Props = { isOpened?: boolean, onClose: Function, - preventBackdropClick: boolean, + preventBackdropClick?: boolean, + preventSideMargin?: boolean, render: Function, } @@ -73,13 +74,14 @@ const Wrapper = styled(Box).attrs({ transform: `translate3d(0, ${p.offset}px, 0)`, }), })` - width: 430px; + margin-left: ${p => (p.preventSideMargin ? 0 : p.theme.sizes.sideBarWidth)}px; + width: 570px; z-index: 2; ` const Body = styled(Box).attrs({ bg: p => p.theme.colors.white, - p: 20, + p: 3, })` border-radius: 5px; ` @@ -87,12 +89,13 @@ const Body = styled(Box).attrs({ export class Modal extends PureComponent { static defaultProps = { onClose: noop, - preventBackdropClick: true, + preventBackdropClick: false, + preventSideMargin: false, isOpened: false, } render() { - const { preventBackdropClick, isOpened, onClose, render } = this.props + const { preventBackdropClick, preventSideMargin, isOpened, onClose, render } = this.props return ( { {(m, isVisible) => ( - + {render({ onClose })} diff --git a/src/components/base/Modal/stories.js b/src/components/base/Modal/stories.js index 09eb8217..6abd2d47 100644 --- a/src/components/base/Modal/stories.js +++ b/src/components/base/Modal/stories.js @@ -8,9 +8,11 @@ const stories = storiesOf('Modal', module) stories.add('basic', () => { const isOpened = boolean('isOpened', true) + const preventSideMargin = boolean('preventSideMargin', true) return ( ( Hey! diff --git a/src/styles/theme.js b/src/styles/theme.js index a5805549..36234024 100644 --- a/src/styles/theme.js +++ b/src/styles/theme.js @@ -1,6 +1,9 @@ // @flow export default { + sizes: { + sideBarWidth: 250, + }, colors: { black: '#000000', white: '#ffffff', From 502c8bba676f6804321f99aab03774463edd78c9 Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 25 Jan 2018 09:59:28 +0100 Subject: [PATCH 2/8] Integrate font-awesome. Use it in SideBar. --- src/components/SideBar/Item.js | 12 +++--------- src/components/SideBar/index.js | 16 ++++++++++++---- src/components/base/Icon.js | 16 ++++++++++++++++ src/renderer/head.js | 8 ++++++++ src/renderer/index.js | 1 + 5 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 src/components/base/Icon.js create mode 100644 src/renderer/head.js diff --git a/src/components/SideBar/Item.js b/src/components/SideBar/Item.js index 46407f99..6e21a70c 100644 --- a/src/components/SideBar/Item.js +++ b/src/components/SideBar/Item.js @@ -15,6 +15,7 @@ import type { Location } from 'react-router' import Box from 'components/base/Box' import Text from 'components/base/Text' +import Icon from 'components/base/Icon' const mapStateToProps: MapStateToProps<*, *, *> = (state, { modal }: any) => ({ // connect router here only to make components re-render @@ -33,6 +34,7 @@ const Container = styled(Box).attrs({ align: 'center', color: 'lead', p: 2, + flow: 2, })` cursor: pointer; color: ${p => (p.isActive ? p.theme.colors.white : '')}; @@ -46,12 +48,6 @@ const Container = styled(Box).attrs({ } ` -const IconWrapper = styled(Box)` - width: 25px; - height: 25px; - border: 2px solid ${p => (p.isActive ? p.theme.colors.blue : 'rgba(255, 255, 255, 0.1)')}; -` - type Props = { children: string, linkTo?: string | null, @@ -86,9 +82,7 @@ function Item({ } isActive={isActive} > - - {icon || null} - + {icon && }
{children} diff --git a/src/components/SideBar/index.js b/src/components/SideBar/index.js index df8e832b..e4f9fe4f 100644 --- a/src/components/SideBar/index.js +++ b/src/components/SideBar/index.js @@ -67,10 +67,18 @@ class SideBar extends PureComponent { {'Menu'}
- {'Dashboard'} - {'Send'} - {'Receive'} - {'Settings'} + + {'Dashboard'} + + + {'Send'} + + + {'Receive'} + + + {'Settings'} +
diff --git a/src/components/base/Icon.js b/src/components/base/Icon.js new file mode 100644 index 00000000..d3e4606f --- /dev/null +++ b/src/components/base/Icon.js @@ -0,0 +1,16 @@ +// @flow + +import React from 'react' +import styled from 'styled-components' +import { fontSize, color } from 'styled-system' + +const Container = styled.div` + ${fontSize}; + ${color}; +` + +export default ({ name, ...props }: { name: string }) => ( + + + +) diff --git a/src/renderer/head.js b/src/renderer/head.js new file mode 100644 index 00000000..f1ff7bf7 --- /dev/null +++ b/src/renderer/head.js @@ -0,0 +1,8 @@ +const list = ['https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'] + +list.forEach(href => { + const tag = document.createElement('link') + tag.setAttribute('rel', 'stylesheet') + tag.setAttribute('href', href) + document.head.appendChild(tag) +}) diff --git a/src/renderer/index.js b/src/renderer/index.js index eb26a1a0..20da31e8 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -17,6 +17,7 @@ import { getLanguage } from 'reducers/settings' import App from 'components/App' import 'styles/global' +import 'renderer/head' if (__PROD__ && __SENTRY_URL__) { Raven.config(__SENTRY_URL__, { allowSecretKey: true }).install() From e47b2fd6fb7595be4031821bfb6b46e04261812a Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 25 Jan 2018 10:28:43 +0100 Subject: [PATCH 3/8] Styles adjustments on theme, icons and modals --- src/components/AccountPage.js | 2 +- src/components/base/Icon.js | 1 + src/components/base/Modal/index.js | 24 ++++++++++++++++++++---- src/styles/theme.js | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/components/AccountPage.js b/src/components/AccountPage.js index 0d50790d..81b5a3c0 100644 --- a/src/components/AccountPage.js +++ b/src/components/AccountPage.js @@ -49,7 +49,7 @@ const Action = styled(Box).attrs({ text-transform: uppercase; &:hover { - color: ${p => p.theme.colors.gray}; + color: ${p => p.theme.colors.grey}; } ` diff --git a/src/components/base/Icon.js b/src/components/base/Icon.js index d3e4606f..6d441189 100644 --- a/src/components/base/Icon.js +++ b/src/components/base/Icon.js @@ -7,6 +7,7 @@ import { fontSize, color } from 'styled-system' const Container = styled.div` ${fontSize}; ${color}; + line-height: 1; ` export default ({ name, ...props }: { name: string }) => ( diff --git a/src/components/base/Modal/index.js b/src/components/base/Modal/index.js index a201acd9..1223a218 100644 --- a/src/components/base/Modal/index.js +++ b/src/components/base/Modal/index.js @@ -16,6 +16,7 @@ import { rgba } from 'styles/helpers' import { closeModal, isModalOpened } from 'reducers/modals' import Box from 'components/base/Box' +import Icon from 'components/base/Icon' type Props = { isOpened?: boolean, @@ -26,7 +27,7 @@ type Props = { } const springConfig = { - stiffness: 350, + stiffness: 400, } const mapStateToProps = (state, { name, isOpened }) => ({ @@ -43,6 +44,7 @@ const mapDispatchToProps = (dispatch, { name, onClose = noop }) => ({ }) const Container = styled(Box).attrs({ + color: 'grey', align: 'center', justify: 'flex-start', sticky: true, @@ -86,6 +88,20 @@ const Body = styled(Box).attrs({ border-radius: 5px; ` +const CloseContainer = styled(Box).attrs({ + p: 2, + color: 'mouse', +})` + cursor: pointer; + position: absolute; + top: 0; + right: 0; + + &:hover { + color: ${p => p.theme.colors.grey}; + } +` + export class Modal extends PureComponent { static defaultProps = { onClose: noop, @@ -127,9 +143,9 @@ export const ModalBody = ({ }) => ( {onClose && ( - - [x] - + + + )} {children} diff --git a/src/styles/theme.js b/src/styles/theme.js index 36234024..0e50215e 100644 --- a/src/styles/theme.js +++ b/src/styles/theme.js @@ -11,7 +11,7 @@ export default { argile: '#eeeeee', blue: '#6193ff', cream: '#f9f9f9', - gray: '#a8b6c2', + grey: '#a8b6c2', grenade: '#ea2e49', lead: '#999999', mouse: '#e2e2e2', From 8b3b838559eae896a63a2ebc137a9733f400791b Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 25 Jan 2018 11:02:21 +0100 Subject: [PATCH 4/8] Add primary style for button --- src/components/base/Button.js | 12 --------- src/components/base/Button/index.js | 37 +++++++++++++++++++++++++++ src/components/base/Button/stories.js | 9 +++++++ 3 files changed, 46 insertions(+), 12 deletions(-) delete mode 100644 src/components/base/Button.js create mode 100644 src/components/base/Button/index.js create mode 100644 src/components/base/Button/stories.js diff --git a/src/components/base/Button.js b/src/components/base/Button.js deleted file mode 100644 index 729b9b28..00000000 --- a/src/components/base/Button.js +++ /dev/null @@ -1,12 +0,0 @@ -// @flow - -import styled from 'styled-components' -import { color } from 'styled-system' - -export default styled.button` - border: none; - height: 50px; - padding: 0 20px; - - ${color}; -` diff --git a/src/components/base/Button/index.js b/src/components/base/Button/index.js new file mode 100644 index 00000000..9e6665c2 --- /dev/null +++ b/src/components/base/Button/index.js @@ -0,0 +1,37 @@ +// @flow + +import React from 'react' +import styled from 'styled-components' +import { space, fontSize, fontWeight, color } from 'styled-system' + +const Base = styled.button.attrs({ + px: 4, + fontSize: 1, +})` + ${space}; + ${color}; + ${fontSize}; + ${fontWeight}; + border-radius: 5px; + border: none; + height: 40px; + box-shadow: ${p => (p.withShadow ? 'rgba(0, 0, 0, 0.2) 0 3px 10px' : '')}; + outline: none; +` + +type Props = { + primary?: boolean, +} + +const Button = ({ primary, ...props }: Props) => { + if (primary) { + return + } + return +} + +Button.defaultProps = { + primary: false, +} + +export default Button diff --git a/src/components/base/Button/stories.js b/src/components/base/Button/stories.js new file mode 100644 index 00000000..afad1735 --- /dev/null +++ b/src/components/base/Button/stories.js @@ -0,0 +1,9 @@ +import React from 'react' +import { storiesOf } from '@storybook/react' + +import Button from 'components/base/Button' + +const stories = storiesOf('Button', module) + +stories.add('basic', () => ) +stories.add('primary', () => ) From 5cfe146422e18aa7132938c971b6d8ed01a00b54 Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 25 Jan 2018 13:51:56 +0100 Subject: [PATCH 5/8] Styling updates for settings --- .eslintrc | 1 + src/components/SettingsPage/Display.js | 10 +++-- src/components/SettingsPage/Profile.js | 35 +++++++++--------- src/components/base/Label.js | 7 +++- src/components/base/Modal/index.js | 5 ++- src/components/modals/AddAccount.js | 51 ++++++++++++++++---------- 6 files changed, 64 insertions(+), 45 deletions(-) diff --git a/.eslintrc b/.eslintrc index 1049b3ec..86f3e0cd 100644 --- a/.eslintrc +++ b/.eslintrc @@ -16,6 +16,7 @@ "import/prefer-default-export": 0, "import/no-named-as-default": 0, "jsx-a11y/anchor-is-valid": 0, + "jsx-a11y/label-has-for": 0, "new-cap": 0, "no-nested-ternary": 0, "no-param-reassign": 0, diff --git a/src/components/SettingsPage/Display.js b/src/components/SettingsPage/Display.js index b5de95c1..6176aab0 100644 --- a/src/components/SettingsPage/Display.js +++ b/src/components/SettingsPage/Display.js @@ -76,8 +76,8 @@ class TabProfile extends PureComponent { return (
- - + + this.handleChangeInput('password.state')(e.target.checked)} - />{' '} - with password - + + {get(inputValue, 'password.state') === true && ( - + { /> )} - - + + diff --git a/src/components/base/Label.js b/src/components/base/Label.js index bd87fd78..38203370 100644 --- a/src/components/base/Label.js +++ b/src/components/base/Label.js @@ -1,6 +1,11 @@ import styled from 'styled-components' +import { fontSize } from 'styled-system' -export default styled.label` +export default styled.label.attrs({ + fontSize: 0, +})` + ${fontSize}; display: block; text-transform: uppercase; + letter-spacing: 1px; ` diff --git a/src/components/base/Modal/index.js b/src/components/base/Modal/index.js index 1223a218..07abf42c 100644 --- a/src/components/base/Modal/index.js +++ b/src/components/base/Modal/index.js @@ -27,7 +27,7 @@ type Props = { } const springConfig = { - stiffness: 400, + stiffness: 350, } const mapStateToProps = (state, { name, isOpened }) => ({ @@ -137,6 +137,7 @@ export class Modal extends PureComponent { export const ModalBody = ({ children, onClose, + ...props }: { children: Element | string, onClose?: Function, @@ -147,7 +148,7 @@ export const ModalBody = ({ )} - {children} + {children} ) diff --git a/src/components/modals/AddAccount.js b/src/components/modals/AddAccount.js index 9770cfa9..ab92db2c 100644 --- a/src/components/modals/AddAccount.js +++ b/src/components/modals/AddAccount.js @@ -14,6 +14,8 @@ import { sendEvent } from 'renderer/events' import { addAccount } from 'actions/accounts' +import Box from 'components/base/Box' +import Text from 'components/base/Text' import Button from 'components/base/Button' import Input from 'components/base/Input' import Label from 'components/base/Label' @@ -23,25 +25,31 @@ import Select from 'components/base/Select' const Steps = { createAccount: (props: Object) => (
-
- - -
- + + + + + + + + +
), connectDevice: () =>
Connect your Ledger
, @@ -270,7 +278,10 @@ class AddAccountModal extends PureComponent { preventBackdropClick onClose={this.handleClose} render={({ onClose }) => ( - + + + {'Add account'} + )} From 36827132d3d113381cf997d780098c2d752b3a66 Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 25 Jan 2018 14:26:04 +0100 Subject: [PATCH 6/8] Better display of balance on account page --- src/components/AccountPage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/AccountPage.js b/src/components/AccountPage.js index 81b5a3c0..64368136 100644 --- a/src/components/AccountPage.js +++ b/src/components/AccountPage.js @@ -66,8 +66,8 @@ class AccountPage extends PureComponent { - - {format(accountData.balance)} + + {format(accountData.balance)} From 01b9aec0341a67cde523aca203cd9d59c11eeb93 Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 25 Jan 2018 14:32:34 +0100 Subject: [PATCH 7/8] Disabled state for tabs items --- src/components/SettingsPage/index.js | 5 +++++ src/components/base/Tabs/index.js | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/SettingsPage/index.js b/src/components/SettingsPage/index.js index 23863f9a..341f7a13 100644 --- a/src/components/SettingsPage/index.js +++ b/src/components/SettingsPage/index.js @@ -67,26 +67,31 @@ class SettingsPage extends PureComponent { }, { key: 'money', + isDisabled: true, title: t('settings.tabs.money'), render: () =>
{'Monnaie'}
, }, { key: 'material', + isDisabled: true, title: t('settings.tabs.material'), render: () =>
{'Matériel'}
, }, { key: 'app', + isDisabled: true, title: t('settings.tabs.app'), render: () =>
{'App (beta)'}
, }, { key: 'tools', + isDisabled: true, title: t('settings.tabs.tools'), render: () =>
{'Outils'}
, }, { key: 'blockchain', + isDisabled: true, title: t('settings.tabs.blockchain'), render: () =>
{'Blockchain'}
, }, diff --git a/src/components/base/Tabs/index.js b/src/components/base/Tabs/index.js index 3d01824b..2d257506 100644 --- a/src/components/base/Tabs/index.js +++ b/src/components/base/Tabs/index.js @@ -16,15 +16,17 @@ const Tab = styled(Tabbable).attrs({ })` border-bottom: 2px solid transparent; border-bottom-color: ${p => (p.isActive ? p.theme.colors.blue : '')}; - color: ${p => (p.isActive ? p.theme.colors.blue : p.theme.colors.steel)}; + color: ${p => + p.isActive ? p.theme.colors.blue : p.isDisabled ? p.theme.colors.grey : p.theme.colors.steel}; margin-bottom: -1px; outline: none; - cursor: ${p => (p.isActive ? 'default' : 'pointer')}; + cursor: ${p => (p.isActive ? 'default' : p.isDisabled ? 'not-allowed' : 'pointer')}; max-width: 200px; ` type Item = { key: string | number, + isDisabled?: boolean, title: string | Element, render: () => Element, } @@ -39,7 +41,12 @@ const Tabs = ({ items, index, onTabClick }: Props) => ( {items.map((item, i) => ( - onTabClick(i)}> + onTabClick(i)} + > {item.title} ))} From d6656b04efc15db17db453fae9a4a18b1d91b60a Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 25 Jan 2018 14:37:52 +0100 Subject: [PATCH 8/8] Clean TopBar --- src/components/SettingsPage/Profile.js | 2 +- src/components/TopBar.js | 59 +++----------------------- 2 files changed, 6 insertions(+), 55 deletions(-) diff --git a/src/components/SettingsPage/Profile.js b/src/components/SettingsPage/Profile.js index 4528b59a..6591e401 100644 --- a/src/components/SettingsPage/Profile.js +++ b/src/components/SettingsPage/Profile.js @@ -84,7 +84,7 @@ class TabProfile extends PureComponent {