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/AccountPage.js b/src/components/AccountPage.js index 0d50790d..64368136 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}; } ` @@ -66,8 +66,8 @@ class AccountPage extends PureComponent { - - {format(accountData.balance)} + + {format(accountData.balance)} 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/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/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 07da6439..e4f9fe4f 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({ @@ -67,10 +67,18 @@ class SideBar extends PureComponent { {'Menu'}
- {'Dashboard'} - {'Send'} - {'Receive'} - {'Settings'} + + {'Dashboard'} + + + {'Send'} + + + {'Receive'} + + + {'Settings'} +
diff --git a/src/components/TopBar.js b/src/components/TopBar.js index f5a97986..beb0f983 100644 --- a/src/components/TopBar.js +++ b/src/components/TopBar.js @@ -5,7 +5,7 @@ import { connect } from 'react-redux' import { ipcRenderer } from 'electron' import type { MapStateToProps, MapDispatchToProps } from 'react-redux' -import type { Device, Devices } from 'types/common' +import type { Devices } from 'types/common' import type { SetCurrentDevice } from 'actions/devices' import { getDevices, getCurrentDevice } from 'reducers/devices' @@ -14,7 +14,6 @@ import { lock } from 'reducers/application' import { hasPassword } from 'reducers/settings' import Box from 'components/base/Box' -import Overlay from 'components/base/Overlay' const mapStateToProps: MapStateToProps<*, *, *> = state => ({ devices: getDevices(state), @@ -32,21 +31,16 @@ type Props = { lock: Function, hasPassword: boolean, devices: Devices, - currentDevice: Device, } type State = { - changeDevice: boolean, sync: { progress: null | boolean, fail: boolean, }, } -const hasDevices = props => props.currentDevice === null && props.devices.length > 0 - class TopBar extends PureComponent { state = { - changeDevice: hasDevices(this.props), sync: { progress: null, fail: false, @@ -57,14 +51,6 @@ class TopBar extends PureComponent { ipcRenderer.on('msg', this.handleAccountSync) } - componentWillReceiveProps(nextProps) { - if (hasDevices(nextProps) && this.props.currentDevice !== null) { - this.setState({ - changeDevice: true, - }) - } - } - componentWillUnmount() { ipcRenderer.removeListener('msg', this.handleAccountSync) } @@ -98,48 +84,20 @@ class TopBar extends PureComponent { } } - handleChangeDevice = () => { - const { devices } = this.props - - if (devices.length > 0) { - this.setState({ - changeDevice: true, - }) - } - } - handleSelectDevice = device => () => { const { setCurrentDevice } = this.props setCurrentDevice(device) - - this.setState({ - changeDevice: false, - }) } handleLock = () => this.props.lock() render() { const { devices, hasPassword } = this.props - const { changeDevice, sync } = this.state + const { sync } = this.state return ( - {changeDevice && ( - - {devices.map(device => ( - - {device.path} - - ))} - - )} {sync.progress === true @@ -148,7 +106,7 @@ class TopBar extends PureComponent { {hasPassword && } - + @@ -156,15 +114,8 @@ class TopBar extends PureComponent { } } -const CountDevices = ({ count, onChangeDevice } = { count: Number, onChangeDevice: Function }) => ( - +const CountDevices = ({ count } = { count: Number }) => ( + 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', () => ) diff --git a/src/components/base/Icon.js b/src/components/base/Icon.js new file mode 100644 index 00000000..6d441189 --- /dev/null +++ b/src/components/base/Icon.js @@ -0,0 +1,17 @@ +// @flow + +import React from 'react' +import styled from 'styled-components' +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/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 a368900e..07abf42c 100644 --- a/src/components/base/Modal/index.js +++ b/src/components/base/Modal/index.js @@ -16,11 +16,13 @@ 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, onClose: Function, - preventBackdropClick: boolean, + preventBackdropClick?: boolean, + preventSideMargin?: boolean, render: Function, } @@ -42,6 +44,7 @@ const mapDispatchToProps = (dispatch, { name, onClose = noop }) => ({ }) const Container = styled(Box).attrs({ + color: 'grey', align: 'center', justify: 'flex-start', sticky: true, @@ -73,26 +76,42 @@ 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; ` +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, - 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 })} @@ -118,17 +137,18 @@ export class Modal extends PureComponent { export const ModalBody = ({ children, onClose, + ...props }: { children: Element | string, onClose?: Function, }) => ( {onClose && ( - - [x] - + + + )} - {children} + {children} ) 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/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} ))} 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'} + )} 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() diff --git a/src/styles/theme.js b/src/styles/theme.js index a5805549..0e50215e 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', @@ -8,7 +11,7 @@ export default { argile: '#eeeeee', blue: '#6193ff', cream: '#f9f9f9', - gray: '#a8b6c2', + grey: '#a8b6c2', grenade: '#ea2e49', lead: '#999999', mouse: '#e2e2e2',