diff --git a/package.json b/package.json index c7ed6f30..5a3d2865 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "cross-env": "^5.1.4", "d3": "^5.0.0", "debug": "^3.1.0", - "downshift": "^1.31.4", + "downshift": "^1.31.6", "electron-store": "^1.3.0", "electron-updater": "^2.21.4", "fuse.js": "^3.2.0", diff --git a/src/components/Breadcrumb/Step.js b/src/components/Breadcrumb/Step.js index c0adc53b..ab0fddcd 100644 --- a/src/components/Breadcrumb/Step.js +++ b/src/components/Breadcrumb/Step.js @@ -1,6 +1,6 @@ // @flow -import React, { Fragment } from 'react' +import React from 'react' import styled from 'styled-components' import Box from 'components/base/Box' @@ -8,9 +8,10 @@ import Box from 'components/base/Box' const RADIUS = 17 const Wrapper = styled(Box).attrs({ - align: 'center', - justify: 'center', + alignItems: 'center', color: p => (p.isActive ? 'wallet' : 'grey'), + grow: true, + justifyContent: 'center', })` width: ${RADIUS}px; flex-shrink: 0; @@ -19,8 +20,8 @@ const Wrapper = styled(Box).attrs({ ` const Number = styled(Box).attrs({ - align: 'center', - justify: 'center', + alignItems: 'center', + justifyContent: 'center', color: 'white', bg: p => (p.isActive ? 'wallet' : 'fog'), ff: 'Rubik|Regular', @@ -33,56 +34,28 @@ const Number = styled(Box).attrs({ width: ${RADIUS}px; ` -const Bar = styled.div` - height: 2px; - background: ${p => p.theme.colors.fog}; - flex-grow: 1; - max-width: 100px; - position: relative; - margin-top: -2px; - - &:after { - background: ${p => p.theme.colors.pearl}; - content: ''; - display: block; - left: 0; - right: 0; - top: 0; - bottom: 0; - position: absolute; - background: ${p => p.theme.colors.wallet}; - transition: transform ease-in-out 0.4s; - transform-origin: center left; - transform: scaleX(${p => (p.isActive ? 1 : 0)}); - } -` - const Label = styled(Box).attrs({ fontSize: 3, ff: 'Museo Sans|Bold', })` position: absolute; - margin-top: 27px; + margin-top: 23px; transition: color ease-in-out 0.1s ${p => (p.isActive ? 0.4 : 0)}s; ` type Props = { number: number, isActive: boolean, - isFirst: boolean, children: any, } function Step(props: Props) { - const { number, isActive, isFirst, children } = props + const { number, isActive, children } = props return ( - - {!isFirst && } - - {number} - - - + + {number} + + ) } diff --git a/src/components/Breadcrumb/index.js b/src/components/Breadcrumb/index.js index 0f8fd615..d92b3278 100644 --- a/src/components/Breadcrumb/index.js +++ b/src/components/Breadcrumb/index.js @@ -15,17 +15,44 @@ type Props = { const Wrapper = styled(Box).attrs({ horizontal: true, - align: 'center', - justify: 'center', + alignItems: 'center', + justifyContent: 'center', + relative: true, })` margin-bottom: 25px; + z-index: 2; +` + +const Bar = styled.div` + background: ${p => p.theme.colors.fog}; + flex-grow: 1; + height: 1px; + left: ${p => p.start}%; + position: absolute; + right: ${p => p.start}%; + top: 8px; + z-index: 1; + + &:after { + background: ${p => p.theme.colors.wallet}; + bottom: 0; + content: ''; + display: block; + left: 0; + position: absolute; + right: ${p => (p.current === 0 ? 0 : `${p.current}%`)}; + top: 0; + transition: right ease-in-out 0.4s; + } ` class Breadcrumb extends PureComponent { render() { const { items, currentStep, ...props } = this.props + const itemsLength = items.length + const start = 100 / itemsLength / 2 return ( - + {items.map((item, i) => ( { ))} + ) } diff --git a/src/components/Breadcrumb/stories.js b/src/components/Breadcrumb/stories.js index 618b4768..7fa1a19f 100644 --- a/src/components/Breadcrumb/stories.js +++ b/src/components/Breadcrumb/stories.js @@ -9,16 +9,22 @@ import Breadcrumb from 'components/Breadcrumb' const stories = storiesOf('Components', module) stories.add('Breadcrumb', () => ( - +
+ +
)) diff --git a/src/components/DeviceConfirm/index.js b/src/components/DeviceConfirm/index.js index 4d2f8f41..5168e76f 100644 --- a/src/components/DeviceConfirm/index.js +++ b/src/components/DeviceConfirm/index.js @@ -49,7 +49,7 @@ const Check = ({ notValid }: { notValid: boolean }) => ( const PushButton = styled(Box)` background: linear-gradient(to bottom, #ffffff, ${p => p.theme.colors.wallet}); - bottom: 53px; + bottom: 48px; height: 28px; left: 205px; position: absolute; diff --git a/src/components/base/Modal/ModalBody.js b/src/components/base/Modal/ModalBody.js index 7678cf23..7ae128b1 100644 --- a/src/components/base/Modal/ModalBody.js +++ b/src/components/base/Modal/ModalBody.js @@ -62,6 +62,7 @@ const CloseContainer = styled(Box).attrs({ position: absolute; top: 0; right: 0; + z-index: 1; &:hover { color: ${p => p.theme.colors.grey}; diff --git a/src/components/base/Modal/index.js b/src/components/base/Modal/index.js index fbd67eaf..9873115e 100644 --- a/src/components/base/Modal/index.js +++ b/src/components/base/Modal/index.js @@ -28,11 +28,20 @@ const springConfig = { const mapStateToProps: Function = ( state, - { name, isOpened }: { name: string, isOpened?: boolean }, -): Object => ({ - isOpened: isOpened || (name && isModalOpened(state, name)), - data: getModalData(state, name), -}) + { name, isOpened, onBeforeOpen }: { name: string, isOpened?: boolean, onBeforeOpen: Function }, +): Object => { + const data = getModalData(state, name) + const modalOpened = isOpened || (name && isModalOpened(state, name)) + + if (onBeforeOpen) { + onBeforeOpen({ data, isOpened: modalOpened }) + } + + return { + isOpened: modalOpened, + data, + } +} const mapDispatchToProps: Function = (dispatch, { name, onClose = noop }): Object => ({ onClose: name @@ -98,12 +107,12 @@ class Pure extends Component { } type Props = { + data?: any, isOpened?: boolean, onClose: Function, onHide?: Function, preventBackdropClick?: boolean, render: Function, - data?: any, } export class Modal extends Component { @@ -138,6 +147,7 @@ export class Modal extends Component { domWrapper.focus() } } + if (didClose) { if (this._lastFocusedElement) { this._lastFocusedElement.focus() @@ -149,7 +159,7 @@ export class Modal extends Component { _lastFocusedElement = null render() { - const { preventBackdropClick, isOpened, onClose, onHide, render, data } = this.props + const { preventBackdropClick, isOpened, onHide, render, data, onClose } = this.props return ( { qrcode.toCanvas(this._canvas, data, { width: size, margin: 0, + color: { + light: '#ffffff00', // transparent background + }, }) } diff --git a/src/components/modals/Receive/03-step-confirm-address.js b/src/components/modals/Receive/03-step-confirm-address.js index 1048edb0..8aecfbc3 100644 --- a/src/components/modals/Receive/03-step-confirm-address.js +++ b/src/components/modals/Receive/03-step-confirm-address.js @@ -30,7 +30,7 @@ const Text = styled(Box).attrs({ ` type Props = { - account: Account, + account: Account | null, addressVerified: null | boolean, device: Device | null, onCheck: Function, @@ -41,16 +41,19 @@ export default (props: Props) => ( {props.t('receive:steps.confirmAddress.action')} {props.t('receive:steps.confirmAddress.text')} - - {props.device && ( - - } - /> - + {props.account && ( + )} + {props.device && + props.account && ( + + } + /> + + )} ) diff --git a/src/components/modals/Receive/04-step-receive-funds.js b/src/components/modals/Receive/04-step-receive-funds.js index 53cc777e..a3af6516 100644 --- a/src/components/modals/Receive/04-step-receive-funds.js +++ b/src/components/modals/Receive/04-step-receive-funds.js @@ -12,7 +12,7 @@ import SelectAccount from 'components/SelectAccount' import RequestAmount from 'components/RequestAmount' type Props = { - account: Account, + account: Account | null, addressVerified: null | boolean, amount: string | number, onChangeAmount: Function, diff --git a/src/components/modals/Receive/index.js b/src/components/modals/Receive/index.js index 500f0a56..c059a886 100644 --- a/src/components/modals/Receive/index.js +++ b/src/components/modals/Receive/index.js @@ -3,9 +3,8 @@ import React, { Fragment, PureComponent } from 'react' import styled from 'styled-components' import { translate } from 'react-i18next' -import get from 'lodash/get' -import type { Account } from '@ledgerhq/wallet-common/lib/types' +import type { Account } from '@ledgerhq/wallet-common/lib/types' import type { T, Device } from 'types/common' import { MODAL_RECEIVE } from 'config/constants' @@ -64,11 +63,11 @@ class ReceiveModal extends PureComponent { _steps = GET_STEPS(this.props.t) - canNext = acc => { - const { stepIndex } = this.state + canNext = () => { + const { account, stepIndex } = this.state if (stepIndex === 0) { - return acc !== null + return account !== null } if (stepIndex === 1) { @@ -160,14 +159,24 @@ class ReceiveModal extends PureComponent { handleChangeAmount = amount => this.setState({ amount }) + handleBeforeOpenModal = ({ data }) => { + const { account } = this.state + if (data && data.account && !account) { + this.setState({ + account: data.account, + stepIndex: 1, + }) + } + } + handleSkipStep = () => this.setState({ addressVerified: false, stepIndex: this._steps.length - 1, // last step }) - renderStep = acc => { - const { amount, addressVerified, deviceSelected, stepIndex } = this.state + renderStep = () => { + const { account, amount, addressVerified, deviceSelected, stepIndex } = this.state const { t } = this.props const step = this._steps[stepIndex] if (!step) { @@ -179,12 +188,12 @@ class ReceiveModal extends PureComponent { const stepProps = { t, - account: acc, + account, ...props(stepIndex === 0, { onChangeAccount: this.handleChangeAccount, }), ...props(stepIndex === 1, { - accountName: acc ? acc.name : undefined, + accountName: account ? account.name : undefined, deviceSelected, onChangeDevice: this.handleChangeDevice, onStatusChange: this.handleChangeStatus, @@ -204,7 +213,7 @@ class ReceiveModal extends PureComponent { return } - renderButton = acc => { + renderButton = () => { const { t } = this.props const { stepIndex } = this.state @@ -222,7 +231,7 @@ class ReceiveModal extends PureComponent { onClick = this.handleNextStep props = { primary: true, - disabled: !this.canNext(acc), + disabled: !this.canNext(), onClick, children: t('common:next'), } @@ -242,46 +251,44 @@ class ReceiveModal extends PureComponent { render() { const { t } = this.props - const { stepIndex, account } = this.state + const { stepIndex } = this.state const canClose = this.canClose() const canPrev = this.canPrev() return ( { - const acc = account || get(data, 'account', null) - return ( - - - {canPrev && ( - - - - {t('common:back')} - - - )} - {t('receive:title')} - - - - {this.renderStep(acc)} - - {stepIndex !== 3 && - canClose && ( - - - {this.renderButton(acc)} - - - )} - - ) - }} + preventBackdropClick={!canClose} + render={({ onClose }) => ( + + + {canPrev && ( + + + + {t('common:back')} + + + )} + {t('receive:title')} + + + + {this.renderStep()} + + {stepIndex !== 3 && + canClose && ( + + + {this.renderButton()} + + + )} + + )} /> ) } diff --git a/src/components/modals/StepConnectDevice.js b/src/components/modals/StepConnectDevice.js index 22469c0e..74a89ea8 100644 --- a/src/components/modals/StepConnectDevice.js +++ b/src/components/modals/StepConnectDevice.js @@ -11,7 +11,7 @@ import DeviceMonit from 'components/DeviceMonitNew' type Props = { accountName?: string, - account?: Account, + account?: Account | null, currency?: Currency | null, deviceSelected: Device | null, onChangeDevice: Function, diff --git a/yarn.lock b/yarn.lock index bb392ac0..c0f84b72 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4673,9 +4673,9 @@ dotenv@^5.0.0, dotenv@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-5.0.1.tgz#a5317459bd3d79ab88cff6e44057a6a3fbb1fcef" -downshift@^1.31.4: - version "1.31.4" - resolved "https://registry.yarnpkg.com/downshift/-/downshift-1.31.4.tgz#72ab0b8ac4c5801221ed098f97817c70899c9d16" +downshift@^1.31.6: + version "1.31.6" + resolved "https://registry.yarnpkg.com/downshift/-/downshift-1.31.6.tgz#467ef5bb81e68d2377c7ed2c602a43f81e68478f" duplexer2@~0.1.4: version "0.1.4"