-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add credit cards * Add opacity to active card types * useCallback * Highlight all for unknown card types * alt card type
- Loading branch information
Showing
10 changed files
with
138 additions
and
8 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,44 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import cn from 'classnames'; | ||
import { keys } from 'ramda'; | ||
import Amex from './amex.svg'; | ||
import Jcb from './jcb.svg'; | ||
import MasterCard from './mastercard.svg'; | ||
import UnionPay from './union_pay.8271208.png'; | ||
import Visa from './visa.svg'; | ||
import styles from './styles.module.css'; | ||
|
||
const cardTypeSrc = { | ||
visa: Visa, | ||
mastercard: MasterCard, | ||
jcb: Jcb, | ||
amex: Amex, | ||
unionpay: UnionPay, | ||
}; | ||
|
||
const cardTypes = keys(cardTypeSrc); | ||
|
||
const isUnknownCardType = cardType => cardTypes.includes(cardType) === false; | ||
|
||
const CreditCards = ({ activeCardType }) => ( | ||
<React.Fragment> | ||
{cardTypes.map(cardType => ( | ||
<img | ||
key={cardType} | ||
className={cn(styles.creditCard, { | ||
[styles.active]: | ||
activeCardType === cardType || isUnknownCardType(activeCardType), | ||
})} | ||
src={cardTypeSrc[cardType]} | ||
alt={cardType} | ||
/> | ||
))} | ||
</React.Fragment> | ||
); | ||
|
||
CreditCards.propTypes = { | ||
activeCardType: PropTypes.string, | ||
}; | ||
|
||
export default CreditCards; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
src/components/Buy/PaymentSection/CreditCards/mastercard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
src/components/Buy/PaymentSection/CreditCards/styles.module.css
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,15 @@ | ||
.creditCard { | ||
width: auto; | ||
height: 22px; | ||
|
||
& + .creditCard { | ||
margin-left: 8px; | ||
} | ||
|
||
opacity: 0.3; | ||
transition: opacity 0.3s; | ||
|
||
&.active { | ||
opacity: 1; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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