From 70b1e1e4afbdfe4605750fc7813d5aea59cf4c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=ABck=20V=C3=A9zien?= Date: Tue, 3 Apr 2018 18:36:32 +0200 Subject: [PATCH 01/10] WIP --- src/components/Breadcrumb/Step.js | 10 +- src/components/DeviceConfirmAddr/index.js | 171 ++++++++++++++++++ src/components/DeviceConfirmAddr/stories.js | 11 ++ src/components/DeviceMonitNew/index.js | 2 +- src/components/base/Button/index.js | 8 +- src/components/base/Label.js | 2 +- src/components/base/Modal/ModalBody.js | 4 + .../modals/Receive/03-step-confirm-address.js | 68 +++++++ src/components/modals/Receive/index.js | 40 +++- src/components/modals/StepConnectDevice.js | 2 +- src/styles/theme.js | 3 +- static/i18n/en/receive.yml | 7 + 12 files changed, 307 insertions(+), 21 deletions(-) create mode 100644 src/components/DeviceConfirmAddr/index.js create mode 100644 src/components/DeviceConfirmAddr/stories.js create mode 100644 src/components/modals/Receive/03-step-confirm-address.js diff --git a/src/components/Breadcrumb/Step.js b/src/components/Breadcrumb/Step.js index e7a94ba7..5e444fcb 100644 --- a/src/components/Breadcrumb/Step.js +++ b/src/components/Breadcrumb/Step.js @@ -10,7 +10,7 @@ const RADIUS = 17 const Wrapper = styled(Box).attrs({ align: 'center', justify: 'center', - color: p => (p.isActive ? 'wallet' : 'fog'), + color: p => (p.isActive ? 'wallet' : 'grey'), })` width: ${RADIUS}px; flex-shrink: 0; @@ -25,13 +25,13 @@ const Number = styled(Box).attrs({ bg: p => (p.isActive ? 'wallet' : 'fog'), ff: 'Rubik|Regular', })` - width: ${RADIUS}px; - height: ${RADIUS}px; border-radius: 50%; font-size: 10px; + height: ${RADIUS}px; line-height: 10px; - box-shadow: ${p => `0 0 0 ${p.isActive ? 4 : 0}px ${p.theme.colors.lightGrey}`}; + padding-left: 1px; transition: all ease-in-out 0.1s ${p => (p.isActive ? 0.4 : 0)}s; + width: ${RADIUS}px; ` const Bar = styled.div` @@ -60,7 +60,7 @@ const Bar = styled.div` const Label = styled(Box).attrs({ fontSize: 3, - ff: 'Museo Sans|Bold', + ff: 'Museo Sans|Regular', })` position: absolute; margin-top: 27px; diff --git a/src/components/DeviceConfirmAddr/index.js b/src/components/DeviceConfirmAddr/index.js new file mode 100644 index 00000000..dbdb1b00 --- /dev/null +++ b/src/components/DeviceConfirmAddr/index.js @@ -0,0 +1,171 @@ +// @flow + +import React from 'react' +import styled from 'styled-components' + +import { rgba } from 'styles/helpers' + +import Box from 'components/base/Box' + +import IconCheck from 'icons/Check' +import IconCross from 'icons/Cross' + +const Wrapper = styled(Box).attrs({ + color: p => (p.notValid ? 'alertRed' : 'wallet'), + relative: true, +})` + transition: all ease-in-out 0.1s; +` + +const WrapperIcon = styled(Box)` + color: ${p => (p.notValid ? p.theme.colors.alertRed : p.theme.colors.positiveGreen)}; + position: absolute; + left: 195px; + top: 18px; + + svg { + transition: all ease-in-out 0.1s; + } +` + +const Check = ({ notValid }: { notValid: boolean }) => ( + + {notValid ? : } + +) + +const PushButton = styled(Box)` + background: linear-gradient(to bottom, #ffffff, ${p => p.theme.colors.wallet}); + height: 35px; + position: absolute; + padding-right: 1px; + width: 1px; + + &:before, + &:after { + border-radius: 50%; + bottom: 0; + content: ' '; + display: block; + position: absolute; + left: 50%; + } + + &:before { + background-color: ${p => p.theme.colors.wallet}; + height: 8px; + margin-left: -4px; + width: 8px; + margin-bottom: -4px; + z-index: 1; + } + + &:after { + background-color: ${p => rgba(p.theme.colors.wallet, 0.4)}; + box-shadow: 0 0 0 1px ${p => rgba(p.theme.colors.wallet, 0.6)}; + height: 14px; + margin-left: -7px; + margin-bottom: -7px; + width: 14px; + } +` + +type Props = { + notValid: boolean, +} + +export default (props: Props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +) diff --git a/src/components/DeviceConfirmAddr/stories.js b/src/components/DeviceConfirmAddr/stories.js new file mode 100644 index 00000000..8f2af667 --- /dev/null +++ b/src/components/DeviceConfirmAddr/stories.js @@ -0,0 +1,11 @@ +// @flow + +import React from 'react' +import { storiesOf } from '@storybook/react' +import { boolean } from '@storybook/addon-knobs' + +import DeviceConfirmAddr from 'components/DeviceConfirmAddr' + +const stories = storiesOf('Components', module) + +stories.add('DeviceConfirmAddr', () => ) diff --git a/src/components/DeviceMonitNew/index.js b/src/components/DeviceMonitNew/index.js index 7d7f8b93..193b69d0 100644 --- a/src/components/DeviceMonitNew/index.js +++ b/src/components/DeviceMonitNew/index.js @@ -140,7 +140,7 @@ class DeviceMonit extends PureComponent { if (render) { return render({ appStatus, - coinType: (account && account.coinType) || coinType, + coinType: account ? account.coinType : coinType, devices, deviceSelected: deviceStatus === 'connected' ? deviceSelected : null, deviceStatus, diff --git a/src/components/base/Button/index.js b/src/components/base/Button/index.js index 7d5670cd..5e1e576a 100644 --- a/src/components/base/Button/index.js +++ b/src/components/base/Button/index.js @@ -11,7 +11,7 @@ import fontFamily from 'styles/styled/fontFamily' const Base = styled.button.attrs({ ff: 'Museo Sans|Regular', - fontSize: 3, + fontSize: p => p.fontSize || 3, px: p => (p.primary ? (p.small ? 2 : 3) : 1), })` ${space}; @@ -71,8 +71,8 @@ function getProps({ disabled, icon, primary }: Object) { }, ), ...props(disabled, { - color: 'white', - bg: 'fog', + color: 'grey', + bg: 'lightFog', }), } } @@ -82,8 +82,8 @@ const Button = (props: Props) => { return ( diff --git a/src/components/base/Label.js b/src/components/base/Label.js index 37a19497..c24d2cea 100644 --- a/src/components/base/Label.js +++ b/src/components/base/Label.js @@ -4,7 +4,7 @@ import { fontSize, color, alignItems } from 'styled-system' import fontFamily from 'styles/styled/fontFamily' export default styled.label.attrs({ - fontSize: 3, + fontSize: p => p.fontSize || 3, ff: 'Museo Sans|Regular', color: 'grey', align: 'center', diff --git a/src/components/base/Modal/ModalBody.js b/src/components/base/Modal/ModalBody.js index 69a2c73c..7678cf23 100644 --- a/src/components/base/Modal/ModalBody.js +++ b/src/components/base/Modal/ModalBody.js @@ -22,6 +22,10 @@ type State = { } class ModalBody extends PureComponent { + static defaultProps = { + onClose: undefined, + } + state = { isHidden: true, } diff --git a/src/components/modals/Receive/03-step-confirm-address.js b/src/components/modals/Receive/03-step-confirm-address.js new file mode 100644 index 00000000..8c9af5e6 --- /dev/null +++ b/src/components/modals/Receive/03-step-confirm-address.js @@ -0,0 +1,68 @@ +// @flow + +import React from 'react' +import styled from 'styled-components' + +import type { Account } from '@ledgerhq/wallet-common/lib/types' +import type { T } from 'types/common' + +import Box from 'components/base/Box' + +import IconInfoCircle from 'icons/InfoCircle' + +const Container = styled(Box).attrs({ + alignItems: 'center', + fontSize: 4, + color: 'dark', +})`` + +const Title = styled(Box).attrs({ + ff: 'Museo Sans|Regular', + fontSize: 6, + mb: 1, +})`` + +const Address = styled(Box).attrs({ + bg: 'lightGrey', + ff: 'Open Sans|SemiBold', + px: 4, + py: 3, + borderRadius: 1, + mt: 2, +})` + border: 1px dashed ${p => p.theme.colors.fog}; + cursor: text; + user-select: text; +` + +const Text = styled(Box).attrs({ + color: 'smoke', + mb: 5, +})` + text-align: center; +` + +const Label = styled(Box).attrs({ + alignItems: 'center', + color: 'graphite', + ff: 'Open Sans|SemiBold', + flow: 1, + horizontal: true, +})`` + +type Props = { + account: Account, + t: T, +} + +export default (props: Props) => ( + + {props.t('receive:steps.confirmAddress.action')} + {props.t('receive:steps.confirmAddress.text')} + +
{props.account.address}
+
+) diff --git a/src/components/modals/Receive/index.js b/src/components/modals/Receive/index.js index 095241a1..eed2abe9 100644 --- a/src/components/modals/Receive/index.js +++ b/src/components/modals/Receive/index.js @@ -1,6 +1,6 @@ // @flow -import React, { PureComponent } from 'react' +import React, { Fragment, PureComponent } from 'react' import { translate } from 'react-i18next' import get from 'lodash/get' import type { Account } from '@ledgerhq/wallet-common/lib/types' @@ -16,6 +16,7 @@ import Modal, { ModalBody, ModalTitle, ModalContent, ModalFooter } from 'compone import StepConnectDevice from 'components/modals/StepConnectDevice' import StepAccount from './01-step-account' +import StepConfirmAddress from './03-step-confirm-address' type Props = { t: T, @@ -31,6 +32,7 @@ type State = { const GET_STEPS = t => [ { label: t('receive:steps.chooseAccount.title'), Comp: StepAccount }, { label: t('receive:steps.connectDevice.title'), Comp: StepConnectDevice }, + { label: t('receive:steps.confirmAddress.title'), Comp: StepConfirmAddress }, ] const INITIAL_STATE = { @@ -60,6 +62,16 @@ class ReceiveModal extends PureComponent { return false } + canClose = () => { + const { stepIndex } = this.state + + if (stepIndex === 2) { + return false + } + + return true + } + handleReset = () => this.setState(INITIAL_STATE) handleNextStep = () => { @@ -122,31 +134,43 @@ class ReceiveModal extends PureComponent { children: t('common:next'), } - return + )} + - + + {account.unit.code}} + /> + = + {rightUnit.code}} + showAllDigits + /> + + ) + } + + render() { + const { withMax, t } = this.props + + return ( + + {withMax ? ( + {this.renderInputs({ style: { width: 156 } })} + ) : ( + this.renderInputs({ grow: true }) + )} + {withMax && ( + + + + )} ) } diff --git a/src/components/RequestAmount/stories.js b/src/components/RequestAmount/stories.js index d4aa88a4..049968ab 100644 --- a/src/components/RequestAmount/stories.js +++ b/src/components/RequestAmount/stories.js @@ -2,6 +2,7 @@ import React, { PureComponent } from 'react' import { storiesOf } from '@storybook/react' +import { text, boolean } from '@storybook/addon-knobs' import { action } from '@storybook/addon-actions' import { accounts } from 'components/SelectAccount/stories' @@ -23,17 +24,21 @@ class Wrapper extends PureComponent { this.setState({ value }) } render() { + const { max, withMax } = this.props const { value } = this.state return ( ) } } -stories.add('RequestAmount', () => ) +stories.add('RequestAmount', () => ( + +)) diff --git a/src/components/SelectAccount/index.js b/src/components/SelectAccount/index.js index cc1f322f..2d098ecd 100644 --- a/src/components/SelectAccount/index.js +++ b/src/components/SelectAccount/index.js @@ -24,7 +24,7 @@ const renderItem = a => { const Icon = getIconByCoinType(a.coinType) const { color } = a.currency return ( - + {Icon && ( @@ -49,8 +49,9 @@ type Props = { t: T, } -const RawSelectAccount = ({ accounts, onChange, value, t }: Props) => ( +const RawSelectAccount = ({ accounts, onChange, value, t, ...props }: Props) => ( - - - + + } + /> ) : ( - {selectedItem && renderSelected ? ( - renderSelected(selectedItem) - ) : ( - {placeholder} - )} + {renderSelectedItem({ selectedItem, renderSelected, placeholder })} - - - + )} {isOpen && diff --git a/src/components/base/Select/stories.js b/src/components/base/Select/stories.js index ba750dd5..75b0c414 100644 --- a/src/components/base/Select/stories.js +++ b/src/components/base/Select/stories.js @@ -2,6 +2,7 @@ import React, { PureComponent } from 'react' import { storiesOf } from '@storybook/react' +import { boolean } from '@storybook/addon-knobs' import Box from 'components/base/Box' import Select from 'components/base/Select' @@ -57,6 +58,7 @@ stories.add('basic', () => ( {onChange => (