Skip to content

Commit 75770bc

Browse files
committed
replaced the payment icons
1 parent e924c34 commit 75770bc

File tree

6 files changed

+125
-125
lines changed

6 files changed

+125
-125
lines changed

package-lock.json

Lines changed: 5 additions & 108 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"bootstrap": "^4.5.2",
1616
"cleave.js": "^1.6.0",
1717
"node-sass": "^4.14.1",
18+
"payment-icons": "^1.2.1",
1819
"random-gradient": "0.0.2",
1920
"react": "^16.13.1",
2021
"react-bootstrap": "^1.3.0",

src/components/Card/Card.js

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import React, { useMemo } from 'react';
2-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
32
import gradient from 'random-gradient';
43
import ReactCardFlip from 'react-card-flip';
54
import ReactTextTransition from "react-text-transition";
65

6+
import visa from 'payment-icons/min/mono/visa.svg';
7+
import mastercard from 'payment-icons/min/mono/mastercard.svg';
8+
import amex from 'payment-icons/min/mono/amex.svg';
9+
import diners from 'payment-icons/min/mono/diners.svg';
10+
import discover from 'payment-icons/min/mono/discover.svg';
11+
import jcb from 'payment-icons/min/mono/jcb.svg';
12+
import unionpay from 'payment-icons/min/mono/unionpay.svg';
13+
import maestro from 'payment-icons/min/mono/maestro.svg';
14+
715
const Card = ({
816
cardHolder,
917
cardNumber,
@@ -22,9 +30,10 @@ const Card = ({
2230
'visa': '^4',
2331
'amex': '^(34|37)',
2432
'mastercard': '^5[1-5]',
33+
'maestro': '^(?:5[0678]\\\\d{0,2}|6304|67\\\\d{0,2})',
2534
'discover': '^6011',
26-
//'unionpay': '^62',
27-
//'troy': '^9792',
35+
'unionpay': '^62',
36+
'jcb': '^(?:35\\d{0,2})',
2837
'diners-club': '^(30[0-5]|36)'
2938
};
3039

@@ -45,6 +54,41 @@ const Card = ({
4554
}, [cardNumber, CARDS]);
4655

4756
const bgGradient = { background: gradient(`tzrhnfd-credit-card`) }
57+
58+
const cardIconsSwitch = (type) => {
59+
let cardIcons;
60+
switch (type) {
61+
case 'visa':
62+
cardIcons = visa;
63+
break;
64+
case 'amex':
65+
cardIcons = amex;
66+
break;
67+
case 'mastercard':
68+
cardIcons = mastercard;
69+
break;
70+
case 'discover':
71+
cardIcons = discover;
72+
break;
73+
case 'unionpay':
74+
cardIcons = unionpay;
75+
break;
76+
case 'diners-club':
77+
cardIcons = diners;
78+
break;
79+
case 'jcb':
80+
cardIcons = jcb;
81+
break;
82+
case 'maestro':
83+
cardIcons = maestro;
84+
break;
85+
default:
86+
return <div className="card__type__image empty" />
87+
}
88+
89+
return <img className="card__type__image" src={cardIcons} alt={type} />
90+
}
91+
4892
return (
4993
<div className="panel">
5094
<ReactCardFlip isFlipped={isCardFlipped}>
@@ -69,11 +113,7 @@ const Card = ({
69113
{ cardHolder }
70114
</div>
71115
<div className="card__type">
72-
{
73-
useCardType === 'credit-card' ?
74-
<FontAwesomeIcon icon={['far', 'credit-card']}/> :
75-
<FontAwesomeIcon icon={['fab', `cc-${useCardType}`]}/>
76-
}
116+
{ cardIconsSwitch(useCardType) }
77117
</div>
78118
</div>
79119
<div className="card card--back" style={bgGradient}>
@@ -85,11 +125,7 @@ const Card = ({
85125
</div>
86126
</div>
87127
<div className="card__type">
88-
{
89-
useCardType === 'credit-card' ?
90-
<FontAwesomeIcon icon={['far', 'credit-card']}/> :
91-
<FontAwesomeIcon icon={['fab', `cc-${useCardType}`]}/>
92-
}
128+
{ cardIconsSwitch(useCardType) }
93129
</div>
94130
</div>
95131
</div>

src/components/Card/Card.scss

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,22 @@
4444
&__type {
4545
bottom: 20px;
4646
font-size: 40px;
47+
height: 38px;
4748
position: absolute;
4849
right: 20px;
50+
width: 60px;
51+
52+
&__image {
53+
background: white;
54+
border-radius: 8px;
55+
background-clip: padding-box;
56+
color: white;
57+
height: 38px;
58+
margin: 0;
59+
padding: 0;
60+
vertical-align: top;
61+
width: 60px;
62+
}
4963
}
5064

5165
&__strip {
@@ -107,6 +121,10 @@
107121
&__number {
108122
margin: 45px 7.5px 15px;
109123
font-size: 16px;
124+
125+
.numbers {
126+
width: 8px !important;
127+
}
110128
}
111129

112130
&__expiry-date,
@@ -117,7 +135,15 @@
117135
&__type {
118136
bottom: 15px;
119137
font-size: 30px;
138+
height: 28px;
120139
right: 15px;
140+
width: 45px;
141+
142+
&__image {
143+
border-radius: 4px;
144+
height: 28px;
145+
width: 45px;
146+
}
121147
}
122148

123149
&__strip {

0 commit comments

Comments
 (0)