Browse Source

Merge pull request #218 from meriadec/master

Update send, receive and account settings modals
master
Loëck Vézien 7 years ago
committed by GitHub
parent
commit
a279b0219c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/components/Breadcrumb/index.js
  2. 10
      src/components/base/Label.js
  3. 32
      src/components/base/Modal/index.js
  4. 51
      src/components/modals/Receive.js
  5. 60
      src/components/modals/Send.js
  6. 109
      src/components/modals/SettingsAccount.js

4
src/components/Breadcrumb/index.js

@ -23,9 +23,9 @@ const Wrapper = styled(Box).attrs({
class Breadcrumb extends PureComponent<Props> { class Breadcrumb extends PureComponent<Props> {
render() { render() {
const { items, currentStep } = this.props const { items, currentStep, ...props } = this.props
return ( return (
<Wrapper> <Wrapper {...props}>
{items.map((item, i) => ( {items.map((item, i) => (
<Step key={i} isActive={i < parseInt(currentStep, 10)} isFirst={i === 0} number={i + 1}> <Step key={i} isActive={i < parseInt(currentStep, 10)} isFirst={i === 0} number={i + 1}>
{item.label} {item.label}

10
src/components/base/Label.js

@ -1,11 +1,15 @@
import styled from 'styled-components' import styled from 'styled-components'
import { fontSize } from 'styled-system' import { fontSize, color } from 'styled-system'
import fontFamily from 'styles/styled/fontFamily'
export default styled.label.attrs({ export default styled.label.attrs({
fontSize: 3, fontSize: 3,
ff: 'Museo Sans|Regular',
color: 'grey',
})` })`
${color};
${fontSize}; ${fontSize};
${fontFamily};
display: block; display: block;
text-transform: uppercase;
letter-spacing: 1px;
` `

32
src/components/base/Modal/index.js

@ -12,6 +12,7 @@ import styled from 'styled-components'
import noop from 'lodash/noop' import noop from 'lodash/noop'
import { rgba } from 'styles/helpers' import { rgba } from 'styles/helpers'
import { radii } from 'styles/theme'
import { closeModal, isModalOpened, getModalData } from 'reducers/modals' import { closeModal, isModalOpened, getModalData } from 'reducers/modals'
@ -83,9 +84,8 @@ const Wrapper = styled(Tabbable).attrs({
const Body = styled(Box).attrs({ const Body = styled(Box).attrs({
bg: p => p.theme.colors.white, bg: p => p.theme.colors.white,
relative: true, relative: true,
})` borderRadius: 1,
border-radius: 5px; })``
`
const CloseContainer = styled(Box).attrs({ const CloseContainer = styled(Box).attrs({
p: 4, p: 4,
@ -220,9 +220,7 @@ export const ModalBody = ({
<IconCross height={16} width={16} /> <IconCross height={16} width={16} />
</CloseContainer> </CloseContainer>
)} )}
<Box p={5} {...props}> <Box {...props}>{children}</Box>
{children}
</Box>
</Body> </Body>
) )
@ -230,4 +228,26 @@ ModalBody.defaultProps = {
onClose: undefined, onClose: undefined,
} }
export const ModalTitle = styled(Box).attrs({
ff: 'Museo Sans|Regular',
fontSize: 6,
color: 'dark',
align: 'center',
p: 5,
})``
export const ModalFooter = styled(Box).attrs({
px: 5,
py: 3,
})`
border-top: 2px solid ${p => p.theme.colors.lightGrey};
border-bottom-left-radius: ${radii[1]}px;
border-bottom-right-radius: ${radii[1]}px;
`
export const ModalContent = styled(Box).attrs({
px: 5,
pb: 5,
})``
export default connect(mapStateToProps, mapDispatchToProps)(Modal) export default connect(mapStateToProps, mapDispatchToProps)(Modal)

51
src/components/modals/Receive.js

@ -10,10 +10,9 @@ import Box from 'components/base/Box'
import Button from 'components/base/Button' import Button from 'components/base/Button'
import Input from 'components/base/Input' import Input from 'components/base/Input'
import Label from 'components/base/Label' import Label from 'components/base/Label'
import Modal, { ModalBody } from 'components/base/Modal' import Modal, { ModalBody, ModalTitle, ModalFooter, ModalContent } from 'components/base/Modal'
import ReceiveBox from 'components/ReceiveBox' import ReceiveBox from 'components/ReceiveBox'
import SelectAccount from 'components/SelectAccount' import SelectAccount from 'components/SelectAccount'
import Text from 'components/base/Text'
import type { Account as AccountType, T } from 'types/common' import type { Account as AccountType, T } from 'types/common'
@ -65,32 +64,32 @@ class ReceiveModal extends PureComponent<Props, State> {
return ( return (
<ModalBody onClose={onClose} flow={3}> <ModalBody onClose={onClose} flow={3}>
<Text fontSize={4} color="graphite"> <ModalTitle>{t('receive:title')}</ModalTitle>
{t('receive:title')} <ModalContent>
</Text> <Box flow={1}>
<Box flow={1}> <Label>Account</Label>
<Label>Account</Label> <SelectAccount value={account} onChange={this.handleChangeInput('account')} />
<SelectAccount value={account} onChange={this.handleChangeInput('account')} /> </Box>
</Box> {account && (
{account && ( <Fragment>
<Fragment> <Box flow={1}>
<Box flow={1}> <Label>Request amount</Label>
<Label>Request amount</Label> <Input
<Input type="number"
type="number" min={0}
min={0} max={account.balance / 1e8}
max={account.balance / 1e8} onChange={this.handleChangeInput('amount')}
onChange={this.handleChangeInput('amount')} />
/> </Box>
</Box> <ReceiveBox account={account} amount={amount} />
<ReceiveBox account={account} amount={amount} /> </Fragment>
</Fragment> )}
)} </ModalContent>
<Box horizontal justifyContent="center"> <ModalFooter horizontal align="center" justify="flex-end">
<Button primary onClick={onClose}> <Button primary onClick={onClose}>
Close {'Close'}
</Button> </Button>
</Box> </ModalFooter>
</ModalBody> </ModalBody>
) )
}} }}

60
src/components/modals/Send.js

@ -1,8 +1,9 @@
// @flow // @flow
import React, { Fragment, PureComponent } from 'react' import React, { PureComponent } from 'react'
import { translate } from 'react-i18next' import { translate } from 'react-i18next'
import get from 'lodash/get' import get from 'lodash/get'
import { getDefaultUnitByCoinType } from '@ledgerhq/currencies'
import type { T } from 'types/common' import type { T } from 'types/common'
@ -12,11 +13,11 @@ import Box from 'components/base/Box'
import Button from 'components/base/Button' import Button from 'components/base/Button'
import Input from 'components/base/Input' import Input from 'components/base/Input'
import Label from 'components/base/Label' import Label from 'components/base/Label'
import Modal, { ModalBody } from 'components/base/Modal' import Modal, { ModalBody, ModalTitle, ModalFooter, ModalContent } from 'components/base/Modal'
import Breadcrumb from 'components/Breadcrumb' import Breadcrumb from 'components/Breadcrumb'
import RecipientAddress from 'components/RecipientAddress' import RecipientAddress from 'components/RecipientAddress'
import SelectAccount from 'components/SelectAccount' import SelectAccount from 'components/SelectAccount'
import Text from 'components/base/Text' import FormattedVal from 'components/base/FormattedVal'
const Steps = { const Steps = {
'1': ({ t, ...props }: Object) => ( '1': ({ t, ...props }: Object) => (
@ -29,9 +30,8 @@ const Steps = {
} }
}} }}
> >
<Box flow={5}> <Box flow={4}>
<Text fontSize={6}>{t('send:title')}</Text> <Box flow={1}>
<Box flow={2}>
<Label>Account to debit</Label> <Label>Account to debit</Label>
<SelectAccount onChange={props.onChangeInput('account')} value={props.value.account} /> <SelectAccount onChange={props.onChangeInput('account')} value={props.value.account} />
</Box> </Box>
@ -43,16 +43,6 @@ const Steps = {
<Label>Amount</Label> <Label>Amount</Label>
<Input onChange={props.onChangeInput('amount')} value={props.value.amount} /> <Input onChange={props.onChangeInput('amount')} value={props.value.amount} />
</Box> </Box>
<Box horizontal alignItems="center">
<Box grow>
<Text>Cancel</Text>
</Box>
<Box justifyContent="flex-end">
<Button type="submit" primary disabled={!props.canSubmit}>
Next
</Button>
</Box>
</Box>
</Box> </Box>
</form> </form>
), ),
@ -157,25 +147,35 @@ class Send extends PureComponent<Props, State> {
render() { render() {
const { step } = this.state const { step } = this.state
const { t } = this.props
const Step = Steps[step]
return ( return (
<Modal <Modal
name={MODAL_SEND} name={MODAL_SEND}
onHide={this.handleHide} onHide={this.handleHide}
render={({ data, onClose }) => { render={({ data, onClose }) => (
const Step = Steps[step] <ModalBody onClose={onClose}>
<ModalTitle>{t('send:title')}</ModalTitle>
return ( <ModalContent>
<Fragment> <Box mb={6} mt={2}>
<ModalBody p={3}>
<Breadcrumb currentStep={step} items={this._items} /> <Breadcrumb currentStep={step} items={this._items} />
</ModalBody> </Box>
<ModalBody onClose={onClose}> <Step {...this.getStepProps(data)} />
<Step {...this.getStepProps(data)} /> </ModalContent>
</ModalBody> <ModalFooter horizontal align="center">
</Fragment> <Box grow>
) <Label>{'Total spent'}</Label>
}} <FormattedVal
color="dark"
val={15496420404}
unit={getDefaultUnitByCoinType(0)}
showCode
/>
</Box>
<Button primary>{'Next'}</Button>
</ModalFooter>
</ModalBody>
)}
/> />
) )
} }

109
src/components/modals/SettingsAccount.js

@ -15,8 +15,7 @@ import { setDataModal, closeModal } from 'reducers/modals'
import Box from 'components/base/Box' import Box from 'components/base/Box'
import Button from 'components/base/Button' import Button from 'components/base/Button'
import Input from 'components/base/Input' import Input from 'components/base/Input'
import Modal, { ModalBody } from 'components/base/Modal' import Modal, { ModalBody, ModalTitle, ModalFooter, ModalContent } from 'components/base/Modal'
import Text from 'components/base/Text'
import Label from 'components/base/Label' import Label from 'components/base/Label'
import IconEdit from 'icons/Edit' import IconEdit from 'icons/Edit'
@ -162,65 +161,61 @@ class SettingsAccount extends PureComponent<Props, State> {
const account = this.getAccount(data) const account = this.getAccount(data)
return ( return (
<ModalBody onClose={onClose} flow={3}> <ModalBody onClose={onClose}>
<Text fontSize={4} color="graphite"> <ModalTitle>{'Account settings'}</ModalTitle>
Account settings <ModalContent flow={4}>
</Text> <Box
<Box alignItems="center"
alignItems="center" flow={2}
flow={2} horizontal
horizontal onMouseEnter={this.handleHoveredName(true)}
onMouseEnter={this.handleHoveredName(true)} onMouseLeave={this.handleHoveredName(false)}
onMouseLeave={this.handleHoveredName(false)} >
> <Box>
<Box> {editName ? (
{editName ? ( <form onSubmit={this.handleSubmitName(account)}>
<form onSubmit={this.handleSubmitName(account)}> <Box alignItems="center" horizontal flow={2}>
<Box alignItems="center" horizontal flow={2}> <Box>
<Box> <Input value={account.name} onChange={this.handleChangeName} />
<Input value={account.name} onChange={this.handleChangeName} /> </Box>
</Box> <Box flow={2} horizontal>
<Box flow={2} horizontal> <Button type="button" onClick={this.handleCancelEditName(data)}>
<Button type="button" onClick={this.handleCancelEditName(data)}> Cancel
Cancel </Button>
</Button> <Button type="submit" primary>
<Button type="submit" primary> Ok
Ok </Button>
</Button> </Box>
</Box> </Box>
</form>
) : (
account.name
)}
</Box>
{!editName &&
nameHovered && (
<Box onClick={this.handleEditName(true)} style={{ cursor: 'pointer' }}>
<IconEdit height={16} width={16} />
</Box> </Box>
</form> )}
) : (
account.name
)}
</Box> </Box>
{!editName && <Box>
nameHovered && ( <Label>{'Minimum confirmations'}</Label>
<Box onClick={this.handleEditName(true)} style={{ cursor: 'pointer' }}> <Input
<IconEdit height={16} width={16} /> type="number"
</Box> min={1}
)} max={100}
</Box> value={account.settings.minConfirmations}
<Box> onChange={this.handleChangeMinConfirmations(account)}
<Label>{'Minimum confirmations'}</Label> />
<Input
type="number"
min={1}
max={100}
value={account.settings.minConfirmations}
onChange={this.handleChangeMinConfirmations(account)}
/>
</Box>
<Box horizontal grow alignItems="flex-end" flow={2}>
<Box grow>
<Button onClick={this.handleArchiveAccount(account)}>
{hasNoTransactions(account) ? 'Remove account' : 'Archive account'}
</Button>
</Box>
<Box grow>
<Button primary>Go to account</Button>
</Box> </Box>
</Box> </ModalContent>
<ModalFooter horizontal justify="flex-end" flow={2}>
<Button onClick={this.handleArchiveAccount(account)}>
{hasNoTransactions(account) ? 'Remove account' : 'Archive account'}
</Button>
<Button primary>Go to account</Button>
</ModalFooter>
</ModalBody> </ModalBody>
) )
}} }}

Loading…
Cancel
Save