Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented select crypto step
- Loading branch information
Showing
22 changed files
with
468 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...s/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/CryptoSelection/CryptoItem/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { | ||
CoinType, | ||
SBPairType, | ||
SupportedCoinsType, | ||
SupportedCoinType | ||
} from 'core/types' | ||
import { fiatToString } from 'core/exchange/currency' | ||
import { | ||
getCoinFromPair, | ||
getFiatFromPair | ||
} from 'data/components/simpleBuy/model' | ||
import { Icon, Text } from 'blockchain-info-components' | ||
import { RatesType } from 'data/types' | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
|
||
const DisplayContainer = styled.div<{ | ||
coinType: SupportedCoinType | ||
}>` | ||
display: flex; | ||
width: 100%; | ||
align-items: center; | ||
box-sizing: border-box; | ||
padding: 16px 40px; | ||
border-bottom: 1px solid ${props => props.theme.grey000}; | ||
&hover { | ||
background-color: ${props => props.theme.grey100}; | ||
} | ||
` | ||
const Display = styled.div` | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
margin-left: 12px; | ||
width: 100%; | ||
cursor: pointer; | ||
font-size: 16px; | ||
font-weight: 500; | ||
color: ${props => props.theme.grey800}; | ||
` | ||
const DisplayName = styled(Text)` | ||
font-weight: 600; | ||
` | ||
|
||
const Rate = styled(Text)` | ||
font-size: 14px; | ||
font-weight: 500; | ||
margin-top: 4px; | ||
color: ${props => props.theme.grey600} !important; | ||
> span { | ||
color: ${props => props.theme.green500}; | ||
} | ||
` | ||
|
||
export type Props = { | ||
onClick: (string) => void | ||
rates: { [key in CoinType]: RatesType } | ||
supportedCoins: SupportedCoinsType | ||
value: SBPairType | ||
} | ||
|
||
const CryptoItem: React.FC<Props> = props => { | ||
const coin = getCoinFromPair(props.value.pair) | ||
const fiat = getFiatFromPair(props.value.pair) | ||
const coinType = props.supportedCoins[coin] | ||
const displayName = coinType.displayName | ||
const icon = coinType.icons.circleFilled | ||
const color = coinType.colorCode | ||
|
||
return ( | ||
<DisplayContainer | ||
coinType={coinType} | ||
data-e2e={`sb${props.value.pair}CurrencySelector`} | ||
role='button' | ||
onClick={props.onClick} | ||
> | ||
<Icon size='32px' color={color} name={icon} /> | ||
<Display> | ||
<DisplayName>{displayName}</DisplayName> | ||
<Rate> | ||
{fiatToString({ | ||
value: props.rates[coin][fiat].last, | ||
unit: fiat | ||
})} | ||
<span>+ xx.x%</span> | ||
</Rate> | ||
</Display> | ||
<Icon name='chevron-right' size='32px' color='grey600' /> | ||
</DisplayContainer> | ||
) | ||
} | ||
|
||
export default CryptoItem |
70 changes: 70 additions & 0 deletions
70
packages/blockchain-wallet-v4-frontend/src/modals/SimpleBuy/CryptoSelection/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { actions, selectors } from 'data' | ||
import { bindActionCreators, Dispatch } from 'redux' | ||
import { | ||
CoinType, | ||
FiatEligibleType, | ||
FiatType, | ||
RemoteDataType, | ||
SBCardType, | ||
SBPairType, | ||
SBPaymentMethodsType, | ||
SupportedCoinsType | ||
} from 'core/types' | ||
import { connect, ConnectedProps } from 'react-redux' | ||
import { getData } from './selectors' | ||
import { RatesType } from 'data/types' | ||
import { RootState } from 'data/rootReducer' | ||
import Failure from './template.failure' | ||
import Loading from './template.loading' | ||
import React, { PureComponent } from 'react' | ||
import Success from './template.success' | ||
|
||
class CryptoSelection extends PureComponent<Props> { | ||
componentDidMount () { | ||
if (this.props.fiatCurrency) { | ||
this.props.simpleBuyActions.fetchSBPairs(this.props.fiatCurrency) | ||
this.props.simpleBuyActions.fetchSBFiatEligible(this.props.fiatCurrency) | ||
} | ||
} | ||
|
||
render () { | ||
return this.props.data.cata({ | ||
Success: val => <Success {...val} {...this.props} />, | ||
Failure: () => <Failure {...this.props} />, | ||
Loading: () => <Loading />, | ||
NotAsked: () => <Loading /> | ||
}) | ||
} | ||
} | ||
|
||
const mapStateToProps = (state: RootState): LinkStatePropsType => ({ | ||
data: getData(state), | ||
fiatCurrency: selectors.components.simpleBuy.getFiatCurrency(state) || 'USD' | ||
}) | ||
|
||
export const mapDispatchToProps = (dispatch: Dispatch) => ({ | ||
formActions: bindActionCreators(actions.form, dispatch), | ||
simpleBuyActions: bindActionCreators(actions.components.simpleBuy, dispatch) | ||
}) | ||
|
||
const connector = connect(mapStateToProps, mapDispatchToProps) | ||
|
||
export type OwnProps = { | ||
handleClose: () => void | ||
} | ||
export type SuccessStateType = { | ||
cards: Array<SBCardType> | ||
eligibility: FiatEligibleType | ||
pairs: Array<SBPairType> | ||
paymentMethods: SBPaymentMethodsType | ||
rates: { [key in CoinType]: RatesType } | ||
supportedCoins: SupportedCoinsType | ||
} | ||
export type LinkStatePropsType = { | ||
data: RemoteDataType<string, SuccessStateType> | ||
fiatCurrency: FiatType | ||
} | ||
export type LinkDispatchPropsType = ReturnType<typeof mapDispatchToProps> | ||
export type Props = OwnProps & ConnectedProps<typeof connector> | ||
|
||
export default connector(CryptoSelection) |
Oops, something went wrong.