Skip to content

Commit

Permalink
First take at send flow refactor, working (#509)
Browse files Browse the repository at this point in the history
* Refactor send flow to fit multisig flow
* Improve send flow user experience

Co-authored-by: Alex Singh <[email protected]>
  • Loading branch information
Schwartz10 and as-dr authored Sep 11, 2020
1 parent 80d9f1b commit 32f294d
Show file tree
Hide file tree
Showing 18 changed files with 6,065 additions and 3,704 deletions.
15 changes: 5 additions & 10 deletions components/Msig/ChangeOwner/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
StepHeader,
Input,
Text,
IconLedger
IconLedger,
Form
} from '../../Shared'
import {
ADDRESS_PROPTYPE,
Expand Down Expand Up @@ -161,13 +162,7 @@ const ChangeOwner = ({ address, balance, close }) => {
close()
}}
/>
<Box
width='100%'
display='flex'
flexDirection='column'
alignItems='center'
mb={7}
>
<Form onSubmit={onSubmit}>
<Box
maxWidth={14}
width={13}
Expand Down Expand Up @@ -291,11 +286,11 @@ const ChangeOwner = ({ address, balance, close }) => {
variant='primary'
title='Next'
disabled={isSubmitBtnDisabled()}
onClick={onSubmit}
type='submit'
/>
</Box>
</Box>
</Box>
</Form>
</>
)
}
Expand Down
3 changes: 2 additions & 1 deletion components/Msig/Shared/Headers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
FILECOIN_NUMBER_PROP
} from '../../../customPropTypes'
import makeFriendlyBalance from '../../../utils/makeFriendlyBalance'
import truncateAddress from '../../../utils/truncateAddress'

export const CardHeader = ({ address, balance, customizingGas }) => {
return (
Expand Down Expand Up @@ -39,7 +40,7 @@ export const CardHeader = ({ address, balance, customizingGas }) => {
alignItems='flex-start'
>
<Text m={0}>From</Text>
<Text m={0}>{address}</Text>
<Text m={0}>{truncateAddress(address)}</Text>
</Box>
</>
)}
Expand Down
169 changes: 79 additions & 90 deletions components/Msig/Withdraw/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
Text,
IconLedger,
Num,
Title
Title,
Form
} from '../../Shared'
import {
ADDRESS_PROPTYPE,
Expand Down Expand Up @@ -164,13 +165,7 @@ const Withdrawing = ({ address, balance, close }) => {
close()
}}
/>
<Box
width='100%'
display='flex'
flex='1'
flexDirection='column'
alignItems='center'
>
<Form onSubmit={onSubmit}>
<Box
maxWidth={14}
width={13}
Expand Down Expand Up @@ -220,39 +215,36 @@ const Withdrawing = ({ address, balance, close }) => {
balance={balance}
customizingGas={false}
/>

<>
<Box width='100%' p={3} border={0} bg='background.screen'>
<Input.Address
label='Recipient'
value={toAddress}
onChange={e => setToAddress(e.target.value)}
error={toAddressError}
disabled={step === 3}
onFocus={() => {
if (toAddressError) setToAddressError('')
}}
/>
</Box>
{step > 1 && (
<Box width='100%' p={3} border={0} bg='background.screen'>
<Input.Address
label='Recipient'
value={toAddress}
onChange={e => setToAddress(e.target.value)}
error={toAddressError}
<Input.Funds
name='amount'
label='Amount'
amount={value.toAttoFil()}
onAmountChange={setValue}
balance={balance}
error={valueError}
setError={setValueError}
// since the ledger device pays the gas fee, we dont include that in the funds input
estimatedTransactionFee={new FilecoinNumber('0', 'attofil')}
disabled={step === 3}
onFocus={() => {
if (toAddressError) setToAddressError('')
}}
/>
</Box>
{step > 1 && (
<Box width='100%' p={3} border={0} bg='background.screen'>
<Input.Funds
name='amount'
label='Amount'
amount={value.toAttoFil()}
onAmountChange={setValue}
balance={balance}
error={valueError}
setError={setValueError}
// since the ledger device pays the gas fee, we dont include that in the funds input
estimatedTransactionFee={
new FilecoinNumber('0', 'attofil')
}
disabled={step === 3}
/>
</Box>
)}
{step > 2 && (
)}
{step > 2 && (
<>
<Box
display='flex'
flexDirection='row'
Expand All @@ -262,65 +254,62 @@ const Withdrawing = ({ address, balance, close }) => {
border={0}
bg='background.screen'
>
<Box>
<Text margin={0}>Transaction Fee</Text>
<Box display='flex' alignItems='center'>
<Text margin={0} color='core.darkgray'>
Paid via
</Text>
<IconLedger height='32px' />{' '}
<Text margin={0} color='core.darkgray'>
{makeFriendlyBalance(wallet.balance, 2, true)} FIL
</Text>
</Box>
</Box>
<Box display='flex' flexDirection='row'>
<Text ml={2} color='core.primary'>
{'< 0.0001 FIL'}
<Text margin={0}>Transaction Fee</Text>
<Box display='flex' alignItems='center'>
<Text margin={0} color='core.darkgray'>
Paid via
</Text>
<IconLedger height='32px' />{' '}
<Text margin={0} color='core.darkgray'>
{makeFriendlyBalance(wallet.balance, 2, true)} FIL
</Text>
</Box>
<Text ml={2} color='core.primary'>
{'< 0.0001 FIL'}
</Text>
</Box>
)}
</>
{step > 2 && (
<Box
display='flex'
flexDirection='row'
alignItems='flex-start'
justifyContent='space-between'
pt={6}
pb={3}
px={3}
bg='background.screen'
borderBottomLeftRadius={3}
borderBottomRightRadius={3}
>
<Title fontSize={4} alignSelf='flex-start'>
Total
</Title>
<Box
display='flex'
flexDirection='column'
textAlign='right'
pl={4}
flexDirection='row'
alignItems='flex-start'
justifyContent='space-between'
pt={6}
pb={3}
px={3}
bg='background.screen'
borderBottomLeftRadius={3}
borderBottomRightRadius={3}
>
<Num
size='l'
css={`
word-wrap: break-word;
`}
color='core.primary'
<Title fontSize={4} alignSelf='flex-start'>
Total
</Title>
<Box
display='flex'
flexDirection='column'
textAlign='right'
pl={4}
>
{value.toFil()} FIL
</Num>
<Num size='m' color='core.darkgray'>
{!converterError && value.isGreaterThan(0)
? `${makeFriendlyBalance(converter.fromFIL(value), 2)}`
: '0'}{' '}
USD
</Num>
<Num
size='l'
css={`
word-wrap: break-word;
`}
color='core.primary'
>
{value.toFil()} FIL
</Num>
<Num size='m' color='core.darkgray'>
{!converterError && value.isGreaterThan(0)
? `${makeFriendlyBalance(
converter.fromFIL(value),
2
)}`
: '0'}{' '}
USD
</Num>
</Box>
</Box>
</Box>
</>
)}
</Box>
</Box>
Expand Down Expand Up @@ -355,11 +344,11 @@ const Withdrawing = ({ address, balance, close }) => {
variant='primary'
title='Next'
disabled={isSubmitBtnDisabled()}
onClick={onSubmit}
type='submit'
/>
</Box>
</Box>
</Box>
</Form>
</>
)
}
Expand Down
6 changes: 1 addition & 5 deletions components/Shared/BalanceCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useConverter } from '../../../lib/Converter'
import ApproximationToggleBtn from './ApproximationToggleBtn'

const BalanceCard = forwardRef(
({ balance, onSend, onReceive, disableButtons, ...props }, ref) => {
({ balance, onSend, disableButtons, ...props }, ref) => {
const { converter, converterError } = useConverter()
const [preciseMode, setPreciseMode] = useState(false)
return (
Expand Down Expand Up @@ -93,10 +93,6 @@ BalanceCard.propTypes = {
* action fired when send button is clicked
*/
onSend: func.isRequired,
/**
* action fired when receive button is clicked
*/
onReceive: func.isRequired,
/**
* determines if the buttons should be disabled or not
*/
Expand Down
16 changes: 16 additions & 0 deletions components/Shared/Form/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { layout, space, flexbox, position } from 'styled-system'
import styled from 'styled-components'

const Form = styled.form`
width: 100%;
display: flex;
flex: 1;
flex-direction: column;
align-items: center;
${position}
${space}
${layout}
${flexbox}
`

export default Form
3 changes: 2 additions & 1 deletion components/Shared/Layout/SidebarLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const Content = styled.div`
flex-basis: 0;
flex-grow: 999;
padding-top: ${props => props.theme.sizes[3]}px;
margin: 0 0.5rem 6rem 0.5rem;
margin: 0 0.5rem 0.5rem 0.5rem;
min-height: 100vh;
min-width: 53%;
`
1 change: 1 addition & 0 deletions components/Shared/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export { default as AccountError } from './AccountCard/Error'
export { default as BalanceCard } from './BalanceCard'
export { default as ApproximationToggleBtn } from './BalanceCard/ApproximationToggleBtn'
export { default as Input } from './Input'
export { default as Form } from './Form'
export { default as Address } from './Address'
export * from './Copy'
export { default as Button } from './Button'
Expand Down
2 changes: 1 addition & 1 deletion components/Wallet/Send.js/ConfirmationCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const OtherWalletTypeConfirm = () => {
<Text color='core.nearblack'>
To complete the transaction, please review the{' '}
<TextHighlight>recipient</TextHighlight> and{' '}
<TextHighlight>amount</TextHighlight> and click &rdquo;Confirm&rdquo; at
<TextHighlight>amount</TextHighlight> and click &rdquo;Send&rdquo; at
the bottom of the page.
</Text>
<Text>
Expand Down
41 changes: 41 additions & 0 deletions components/Wallet/Send.js/HeaderText.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react'
import PropTypes from 'prop-types'

import { Text } from '../../Shared'
import { LEDGER } from '../../../constants'

const HeaderText = ({ step, customizingGas, walletType }) => {
let text = ''

switch (step) {
case 1:
text =
"First, please confirm the account you're sending from, and the recipient you want to send to."
break
case 2:
text = "Next, please choose an amount of FIL you'd like to withdraw."
break
case 3:
text = 'Please review the transaction details.'
break
case 4:
if (walletType === LEDGER)
text = 'Please confirm the transaction on your Ledger device.'
break
default:
text = ''
}

if (customizingGas)
text = 'Please select the custom gas fee for this transaction.'

return <Text textAlign='center'>{text}</Text>
}

HeaderText.propTypes = {
step: PropTypes.number.isRequired,
customizingGas: PropTypes.bool.isRequired,
walletType: PropTypes.string.isRequired
}

export default HeaderText
Loading

0 comments on commit 32f294d

Please sign in to comment.