Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(recurring buy): fixes several small design issues related to recurring buy #3467

Merged
merged 3 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1252,13 +1252,11 @@ type MessagesType = {
'modals.recurringbuys.time_options.monthly': 'Monthly'

'modals.recurringbuys.get_started.title': 'Set Up a Recurring Buy'
'modals.recurringbuys.get_started.description': 'Buy {amount} of {currency} every day, week or month with a Recurring Buy. No need to ever time the market.'
'modals.recurringbuys.get_started.description': 'Buy {amount} of {outputCurrency} every day, week or month with a Recurring Buy. No need to ever time the market.'
'modals.recurringbuys.get_started.buy_amount_of_currency': 'Buy {amount} of {currency}'
'modals.recurringbuys.get_started.get_started': 'Get Started'
'modals.recurringbuys.get_started.maybe_later': 'Maybe Later'

'modals.recurringbuys.get_started.title': 'Set Up a Recurring Buy'
'modals.recurringbuys.get_started.description': 'Buy {amount} of {currency} every day, week or month with a Recurring Buy. No need to ever time the market.'
'modals.recurringbuys.get_started.get_started': 'Get Started'
'modals.recurringbuys.get_started.maybe_later': 'Maybe Later'

Expand Down Expand Up @@ -1904,6 +1902,7 @@ type MessagesType = {
'scenes.borrow.warning.safe': 'Your collateralization ratio is <span class="green600">{currentRatio}</span>, no action needed at this time.'
'scenes.borrow.warning.unsafe': 'Your collateralization ratio is below {unsafeRatio}. Your loan is in danger of being liquidated.'
'scenes.buysell.exchangecheckout.rate': "The rate offered by your region's exchange partner. May include fees."
'scenes.coin.recurringbuy.next_buy_is_today': 'Next Buy is Today'
'scenes.coin.recurringbuy.next_buy_on_date': 'Next Buy on {date}'
'scenes.coin.recurringbuy.next_sell_on_date': 'Next Sell on {date}'
'scenes.coin.recurringbuy.next_swap_on_date': 'Next Swap on {date}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ export default {
}

export const Default = (args) => <SavedRecurringBuy {...args} />
export const Today = (args) => <SavedRecurringBuy {...args} nextPayment={new Date()} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react'
import { IntlProvider } from 'react-intl'
import { ComponentMeta, ComponentStory } from '@storybook/react'

import GettingStarted from './GettingStarted'

export default {
args: {
amount: '$20',
close: () => {},
nextStep: () => {},
outputCurrency: 'BTC'
},
component: GettingStarted,
decorators: [
(Story) => (
<IntlProvider locale='en'>
<div style={{ display: 'flex', height: '100vh' }}>
<div style={{ border: '1px solid #ddd', width: '480px' }}>
<Story />
</div>
</div>
</IntlProvider>
)
],
title: 'Flyouts/RecurringBuy/GettingStarted'
} as ComponentMeta<typeof GettingStarted>

export const Default: ComponentStory<typeof GettingStarted> = (args) => <GettingStarted {...args} />
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,12 @@ import { FormattedMessage } from 'react-intl'
import styled from 'styled-components'

import { Button, Image, Link, Text } from 'blockchain-info-components'
import { FlyoutFooter, FlyoutHeader, FlyoutWrapper } from 'components/Flyout'
import { getBaseAmount } from 'data/components/simpleBuy/model'
import { FiatType } from 'core/types'

import { Props as _P } from '.'

const Wrapper = styled.div`
display: flex;
flex-direction: column;
width: 480px;
height: 100vh;
`
const MainContent = styled.div`
display: flex;
flex-direction: column;
flex: 1;
justify-content: center;
`
import Container from '../Container'
import Content from '../Content'
import Footer from '../Footer'
import Header from '../Header'

const ContentWrapper = styled.div`
display: flex;
Expand All @@ -41,58 +30,54 @@ const Description = styled(Text)`
text-align: center;
line-height: 24px;
font-size: 14px;
margin: 0 25px;
color: ${(props) => props.theme.grey900};
`

const FooterWrapper = styled(FlyoutWrapper)`
padding-top: 0px;
`
const GetStarted = ({ close, nextStep, order }: Props) => {
const amount = getBaseAmount(order)
const currency = order.outputCurrency
const GettingStarted = ({ amount, close, nextStep, outputCurrency }: Props) => {
const closeModal = useCallback(() => {
close()
}, [])

return (
<Wrapper>
<FlyoutHeader data-e2e='RecurringBuysCloseButton' mode='close' onClick={closeModal} />
<MainContent>
<ContentWrapper>
<Image name='recurring-buy-get-started' height='130px' width='222px' />
</ContentWrapper>
<TextContentWrapper>
<Container>
<Header data-e2e='RecurringBuysCloseButton' mode='close' onClick={closeModal} />
<Content mode='middle'>
<div>
<ContentWrapper>
<Text size='20px' weight={600} color='grey900' lineHeight='30px'>
<FormattedMessage
id='modals.recurringbuys.get_started.title'
defaultMessage='Set Up a Recurring Buy'
/>
</Text>
<Image name='recurring-buy-get-started' height='130px' width='222px' />
</ContentWrapper>
<>
<TextContentWrapper>
<ContentWrapper>
<Text size='20px' weight={600} color='grey900' lineHeight='30px'>
<FormattedMessage
id='modals.recurringbuys.get_started.title'
defaultMessage='Set Up a Recurring Buy'
/>
</Text>
</ContentWrapper>
<Description>
<FormattedMessage
id='modals.recurringbuys.get_started.description'
defaultMessage='Buy {amount} of {currency} every day, week or month with a Recurring Buy. No need to ever time the market.'
defaultMessage='Buy {amount} of {outputCurrency} every day, week or month with a Recurring Buy. No need to ever time the market.'
values={{
amount,
currency
outputCurrency
}}
/>
<Link
size='16px'
size='14px'
weight={500}
target='_blank'
href='https://support.blockchain.com/hc/en-us/'
>
<FormattedMessage id='buttons.learn_more_arrow' defaultMessage='Learn more ->' />
</Link>
</Description>
</>
</TextContentWrapper>
</MainContent>
<FlyoutFooter>
</TextContentWrapper>
</div>
</Content>
<Footer>
<Button
nature='primary'
data-e2e='getStartedWithRecurringBuys'
Expand Down Expand Up @@ -121,12 +106,16 @@ const GetStarted = ({ close, nextStep, order }: Props) => {
defaultMessage='Maybe Later'
/>
</Button>
</FlyoutFooter>
</Wrapper>
</Footer>
</Container>
)
}

type OwnProps = { nextStep: () => void }
type Props = _P & OwnProps
export type Props = {
amount: string
close: () => void
nextStep: () => void
outputCurrency: string
}

export default GetStarted
export default GettingStarted
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useCallback } from 'react'
import { FormattedMessage } from 'react-intl'
import moment from 'moment'
import styled from 'styled-components'

import { Banner, Button } from 'blockchain-info-components'
import { FiatType, SBPaymentTypes } from 'core/types'
Expand All @@ -15,6 +16,10 @@ import Footer from './Footer'
import Header from './Header'
import { getPaymentMethodText, getPeriodSubTitleText, getPeriodTitleText } from './model'

const StyledBanner = styled(Banner)`
border: unset;
`

const RecurringBuyDetails = ({
closeClick,
complete,
Expand Down Expand Up @@ -47,7 +52,7 @@ const RecurringBuyDetails = ({
<Content mode='top'>
<AmountSubHeader
data-e2e='recurringBuyAmount'
subTitle={<Banner {...bannerProps} />}
subTitle={<StyledBanner {...bannerProps} />}
title={`${amountString} of ${crypto}`}
/>
<CheckoutRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import FlyoutFooter from './Footer'
import FrequencyScreen from './FrequencyScreen'
// These are the newest versions of flyout layouts and should eventually replace/integrate FlyoutWrapper etc.
import FlyoutHeader from './Header'
import RecurringBuyGettingStarted from './RecurringBuy/GettingStarted'
import RecurringBuyDetails from './RecurringBuyDetails'
import RecurringBuyRemoveConfirm from './RecurringBuyRemoveConfirm'

Expand All @@ -25,6 +26,7 @@ export {
FlyoutHeader,
FrequencyScreen,
RecurringBuyDetails,
RecurringBuyGettingStarted,
RecurringBuyRemoveConfirm
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { FormattedMessage } from 'react-intl'
import moment from 'moment'
import moment, { Moment } from 'moment'

import { SBPaymentTypes } from '../../../../blockchain-wallet-v4/src/network/api/simpleBuy/types'
import { RecurringBuyPeriods } from '../../data/components/recurringBuy/types'
Expand Down Expand Up @@ -128,18 +128,31 @@ const getPeriodText = (period: RecurringBuyPeriods): React.ReactNode => {
return text
}

const getActionText = (action: ActionEnum, date: string | number) => {
const getActionText = (action: ActionEnum, nextDate: string | number) => {
let text
let isToday = false
let date: Moment | string = moment()

if (nextDate) {
isToday = moment(nextDate).calendar().startsWith('Today')
date = moment(nextDate)
}

date = date.format('ddd, MMMM Do')

switch (action) {
default:
case ActionEnum.BUY:
text = (
text = isToday ? (
<FormattedMessage
id='scenes.coin.recurringbuy.next_buy_is_today'
defaultMessage='Next Buy is Today'
/>
) : (
<FormattedMessage
id='scenes.coin.recurringbuy.next_buy_on_date'
defaultMessage='Next Buy on {date}'
values={{
date: moment(date).format('ddd, MMMM Do')
}}
values={{ date }}
/>
)
break
Expand All @@ -148,9 +161,7 @@ const getActionText = (action: ActionEnum, date: string | number) => {
<FormattedMessage
id='scenes.coin.recurringbuy.next_sell_on_date'
defaultMessage='Next Sell on {date}'
values={{
date: moment(date).format('ddd, MMMM Do')
}}
values={{ date }}
/>
)
break
Expand All @@ -159,9 +170,7 @@ const getActionText = (action: ActionEnum, date: string | number) => {
<FormattedMessage
id='scenes.coin.recurringbuy.next_deposit_on_date'
defaultMessage='Next Deposit on {date}'
values={{
date: moment(date).format('ddd, MMMM Do')
}}
values={{ date }}
/>
)
break
Expand All @@ -170,9 +179,7 @@ const getActionText = (action: ActionEnum, date: string | number) => {
<FormattedMessage
id='scenes.coin.recurringbuy.next_withdrawal_on_date'
defaultMessage='Next Withdrawal on {date}'
values={{
date: moment(date).format('ddd, MMMM Do')
}}
values={{ date }}
/>
)
break
Expand All @@ -181,9 +188,7 @@ const getActionText = (action: ActionEnum, date: string | number) => {
<FormattedMessage
id='scenes.coin.recurringbuy.next_swap_on_date'
defaultMessage='Next Swap on {date}'
values={{
date: moment(date).format('ddd, MMMM Do')
}}
values={{ date }}
/>
)
break
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import React, { useCallback } from 'react'
import { connect, ConnectedProps } from 'react-redux'

import { RecurringBuyGettingStarted } from 'components/Flyout'
import { SBOrderType } from 'core/types'
import { selectors } from 'data'
import { getCounterAmount } from 'data/components/simpleBuy/model'
import { RootState } from 'data/rootReducer'
import { RecurringBuyStepType } from 'data/types'

import { Props as _P } from '..'
import Success from './template.success'

const GetStartedContainer = (props: Props) => {
const GetStartedContainer = ({ close, order, recurringBuyActions }: Props) => {
const nextStep = useCallback(
() =>
props.recurringBuyActions.setStep({
recurringBuyActions.setStep({
step: RecurringBuyStepType.FREQUENCY
}),
[RecurringBuyStepType.FREQUENCY]
)
const { outputCurrency } = order
const amount = getCounterAmount(order)
const gettingStartedProps = { amount, close, nextStep, outputCurrency }

return <Success nextStep={nextStep} {...props} />
return <RecurringBuyGettingStarted {...gettingStartedProps} />
}

const mapStateToProps = (state: RootState) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AnimatedCarousel extends React.PureComponent<Props, State> {
}

handleClick = (index: number) => {
this.props.stepChange(index)
this.setState({ index })
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import styled from 'styled-components'
import animationData from '../graph.json'

const GraphAnimation = styled.div`
background-color: #ffffff;
background-color: ${(props) => props.theme.white};
width: 100%;
height: 100%;
height: 14.4rem;
display: block;
overflow: hidden;
transform: translate3d(0, 0, 0);
text-align: center;
opacity: 1;
background-image: none;

& > svg {
height: 10.4rem !important;
}
`

const AnimatedGraph = ({ stepIndex }: { stepIndex: number }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Slide = styled.div`
height: 100%;
`
const SlideStart = styled(Slide)`
justify-content: flex-start;
justify-content: center;
`

const SlideContent = styled.div`
Expand Down
Loading