Skip to content

Commit

Permalink
feat: add fontcolor props
Browse files Browse the repository at this point in the history
Allows you to choose the color of the text on the card, since the current color does not provide a good view of the data.
  • Loading branch information
AlvaroBrasilia committed Oct 27, 2020
1 parent 960e842 commit a7aaade
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
9 changes: 9 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ export default function App() {
name="John J. Doe"
/>
</View>
<View style={styles.cardContainer}>
<CreditCardDisplay
number={3542424242424242}
cvc={123}
expiration="06/21"
name="John J. Doe"
fontColor="#222"
/>
</View>
</ScrollView>
</View>
);
Expand Down
15 changes: 10 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ type Props = {
/** Base font size to use. Will scale all displayed text. default: 20 */
fontSize?: number;

/** Text font color. Default: #FFFFFF (White) */
fontColor?: string;

/** Friction for the card flip. I couldn't figure out what this does, but I'm just passing it to `react-native-flip-card` if anyone wants it */
friction?: number;

Expand All @@ -52,6 +55,7 @@ const defaultProps = {
height: 190,
width: 300,
fontSize: 15,
fontColor: '#FFFFFF',
friction: 6,
flipped: false,
borderRadius: 20,
Expand Down Expand Up @@ -139,7 +143,7 @@ const CreditCardDisplay = (props: Props) => {
style={{
fontSize: props.fontSize,
alignSelf: 'center',
color: '#222',
color: props.fontColor,
}}
>
{creditcardutils.formatCardNumber(String(props.number))}
Expand All @@ -153,6 +157,7 @@ const CreditCardDisplay = (props: Props) => {
style={{
...styles.groupLabel,
fontSize: props.fontSize * 0.7,
color: props.fontColor,
textAlign: 'right',
}}
>
Expand All @@ -162,7 +167,7 @@ const CreditCardDisplay = (props: Props) => {
<Text
style={{
fontSize: props.fontSize * 0.7,
color: '#222',
color: props.fontColor,
}}
>
{props.since}
Expand All @@ -178,6 +183,7 @@ const CreditCardDisplay = (props: Props) => {
style={{
...styles.groupLabel,
fontSize: props.fontSize * 0.7,
color: props.fontColor,
textAlign: 'center',
}}
>
Expand All @@ -187,7 +193,7 @@ const CreditCardDisplay = (props: Props) => {
<Text
style={{
fontSize: props.fontSize * 0.7,
color: '#222',
color: props.fontColor,
}}
>
{creditcardutils.formatCardExpiry(props.expiration)}
Expand All @@ -209,7 +215,7 @@ const CreditCardDisplay = (props: Props) => {
style={{
fontSize: props.fontSize,
marginTop: 5,
color: '#222',
color: props.fontColor,
}}
>
{props.name}
Expand Down Expand Up @@ -256,7 +262,6 @@ const styles = StyleSheet.create({
marginRight: '2%',
},
groupLabel: {
color: '#333',
textAlignVertical: 'center',
marginRight: '2%',
},
Expand Down

0 comments on commit a7aaade

Please sign in to comment.