Skip to content

Commit

Permalink
Fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
sbycrosz committed Dec 26, 2017
1 parent 6933160 commit be9dfb9
Show file tree
Hide file tree
Showing 9 changed files with 1,558 additions and 94 deletions.
5 changes: 3 additions & 2 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ export default class Example extends Component {
state = { useLiteCreditCardInput: false };

_onChange = (formData) => console.log(JSON.stringify(formData, null, " "));
_onFocus = (field) => console.log('focusing', field);
_onFocus = (field) => console.log("focusing", field);
_setUseLiteCreditCardInput = (useLiteCreditCardInput) => this.setState({ useLiteCreditCardInput });

render() {
return (
<View style={s.container}>
<Switch
style={s.switch}
onValueChange={(useLiteCreditCardInput) => this.setState({ useLiteCreditCardInput })}
onValueChange={this._setUseLiteCreditCardInput}
value={this.state.useLiteCreditCardInput} />

{ this.state.useLiteCreditCardInput ?
Expand Down
9 changes: 0 additions & 9 deletions example/App.test.js

This file was deleted.

38 changes: 19 additions & 19 deletions src/CCInput.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from "react";
import PropTypes from 'prop-types';
import PropTypes from "prop-types";
import {
View,
Text,
Expand Down Expand Up @@ -72,27 +72,27 @@ export default class CCInput extends Component {
additionalInputProps } = this.props;
return (
<TouchableOpacity onPress={this.focus}
activeOpacity={0.99}>
activeOpacity={0.99}>
<View style={[containerStyle]}>
{ !!label && <Text style={[labelStyle]}>{label}</Text>}
<TextInput ref="input"
{...additionalInputProps}
keyboardType={keyboardType}
autoCapitalise="words"
autoCorrect={false}
style={[
s.baseInputStyle,
inputStyle,
((validColor && status === "valid") ? { color: validColor } :
(invalidColor && status === "invalid") ? { color: invalidColor } :
{}),
]}
underlineColorAndroid={"transparent"}
placeholderTextColor={placeholderColor}
placeholder={placeholder}
value={value}
onFocus={this._onFocus}
onChangeText={this._onChange} />
{...additionalInputProps}
keyboardType={keyboardType}
autoCapitalise="words"
autoCorrect={false}
style={[
s.baseInputStyle,
inputStyle,
((validColor && status === "valid") ? { color: validColor } :
(invalidColor && status === "invalid") ? { color: invalidColor } :
{}),
]}
underlineColorAndroid={"transparent"}
placeholderTextColor={placeholderColor}
placeholder={placeholder}
value={value}
onFocus={this._onFocus}
onChangeText={this._onChange} />
</View>
</TouchableOpacity>
);
Expand Down
22 changes: 11 additions & 11 deletions src/CardView.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from "react";
import PropTypes from 'prop-types';
import PropTypes from "prop-types";
import {
View,
ImageBackground,
Expand Down Expand Up @@ -127,21 +127,21 @@ export default class CardView extends Component {
return (
<View style={[s.cardContainer, containerSize]}>
<FlipCard style={{ borderWidth: 0 }}
flipHorizontal
flipVertical={false}
friction={10}
perspective={2000}
clickable={false}
flip={shouldFlip}>
flipHorizontal
flipVertical={false}
friction={10}
perspective={2000}
clickable={false}
flip={shouldFlip}>
<ImageBackground style={[BASE_SIZE, s.cardFace, transform]}
source={imageFront}>
source={imageFront}>
<Image style={[s.icon]}
source={Icons[brand]} />
source={Icons[brand]} />
<Text style={[s.baseText, { fontFamily }, s.number, !number && s.placeholder, focused === "number" && s.focused]}>
{ !number ? placeholder.number : number }
</Text>
<Text style={[s.baseText, { fontFamily }, s.name, !name && s.placeholder, focused === "name" && s.focused]}
numberOfLines={1}>
numberOfLines={1}>
{ !name ? placeholder.name : name.toUpperCase() }
</Text>
<Text style={[s.baseText, { fontFamily }, s.expiryLabel, s.placeholder, focused === "expiry" && s.focused]}>
Expand All @@ -156,7 +156,7 @@ export default class CardView extends Component {
</Text> }
</ImageBackground>
<ImageBackground style={[BASE_SIZE, s.cardFace, transform]}
source={imageBack}>
source={imageBack}>
<Text style={[s.baseText, s.cvc, !cvc && s.placeholder, focused === "cvc" && s.focused]}>
{ !cvc ? placeholder.cvc : cvc }
</Text>
Expand Down
50 changes: 25 additions & 25 deletions src/CreditCardInput.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from "react";
import PropTypes from 'prop-types';
import PropTypes from "prop-types";
import ReactNative, {
NativeModules,
View,
Expand Down Expand Up @@ -149,39 +149,39 @@ export default class CreditCardInput extends Component {
return (
<View style={s.container}>
<CreditCard focused={focused}
brand={type}
scale={cardScale}
fontFamily={cardFontFamily}
imageFront={cardImageFront}
imageBack={cardImageBack}
customIcons={cardBrandIcons}
name={requiresName ? name : " "}
number={number}
expiry={expiry}
cvc={cvc} />
brand={type}
scale={cardScale}
fontFamily={cardFontFamily}
imageFront={cardImageFront}
imageBack={cardImageBack}
customIcons={cardBrandIcons}
name={requiresName ? name : " "}
number={number}
expiry={expiry}
cvc={cvc} />
<ScrollView ref="Form"
horizontal
keyboardShouldPersistTaps="always"
scrollEnabled={allowScroll}
showsHorizontalScrollIndicator={false}
style={s.form}>
horizontal
keyboardShouldPersistTaps="always"
scrollEnabled={allowScroll}
showsHorizontalScrollIndicator={false}
style={s.form}>
<CCInput {...this._inputProps("number")}
keyboardType="numeric"
containerStyle={[s.inputContainer, inputContainerStyle, { width: CARD_NUMBER_INPUT_WIDTH }]} />
keyboardType="numeric"
containerStyle={[s.inputContainer, inputContainerStyle, { width: CARD_NUMBER_INPUT_WIDTH }]} />
<CCInput {...this._inputProps("expiry")}
keyboardType="numeric"
containerStyle={[s.inputContainer, inputContainerStyle, { width: EXPIRY_INPUT_WIDTH }]} />
keyboardType="numeric"
containerStyle={[s.inputContainer, inputContainerStyle, { width: EXPIRY_INPUT_WIDTH }]} />
{ requiresCVC &&
<CCInput {...this._inputProps("cvc")}
keyboardType="numeric"
containerStyle={[s.inputContainer, inputContainerStyle, { width: CVC_INPUT_WIDTH }]} /> }
keyboardType="numeric"
containerStyle={[s.inputContainer, inputContainerStyle, { width: CVC_INPUT_WIDTH }]} /> }
{ requiresName &&
<CCInput {...this._inputProps("name")}
containerStyle={[s.inputContainer, inputContainerStyle, { width: NAME_INPUT_WIDTH }]} /> }
containerStyle={[s.inputContainer, inputContainerStyle, { width: NAME_INPUT_WIDTH }]} /> }
{ requiresPostalCode &&
<CCInput {...this._inputProps("postalCode")}
keyboardType="numeric"
containerStyle={[s.inputContainer, inputContainerStyle, { width: POSTAL_CODE_INPUT_WIDTH }]} /> }
keyboardType="numeric"
containerStyle={[s.inputContainer, inputContainerStyle, { width: POSTAL_CODE_INPUT_WIDTH }]} /> }
</ScrollView>
</View>
);
Expand Down
18 changes: 9 additions & 9 deletions src/Icons.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const Icons = {
cvc: require('./icons/stp_card_cvc.png'),
cvc_amex: require('./icons/stp_card_cvc_amex.png'),
'american-express': require('./icons/stp_card_amex.png'),
'diners-club': require('./icons/stp_card_diners.png'),
'master-card': require('./icons/stp_card_mastercard.png'),
discover: require('./icons/stp_card_discover.png'),
jcb: require('./icons/stp_card_jcb.png'),
placeholder: require('./icons/stp_card_unknown.png'),
visa: require('./icons/stp_card_visa.png'),
cvc: require("./icons/stp_card_cvc.png"),
cvc_amex: require("./icons/stp_card_cvc_amex.png"),
"american-express": require("./icons/stp_card_amex.png"),
"diners-club": require("./icons/stp_card_diners.png"),
"master-card": require("./icons/stp_card_mastercard.png"),
discover: require("./icons/stp_card_discover.png"),
jcb: require("./icons/stp_card_jcb.png"),
placeholder: require("./icons/stp_card_unknown.png"),
visa: require("./icons/stp_card_visa.png"),
};

export default Icons;
24 changes: 12 additions & 12 deletions src/LiteCreditCardInput.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from "react";
import PropTypes from 'prop-types';
import PropTypes from "prop-types";
import {
View,
Text,
Expand Down Expand Up @@ -149,8 +149,8 @@ export default class LiteCreditCardInput extends Component {
showRightPart ? s.hidden : s.expanded,
]}>
<CCInput {...this._inputProps("number")}
keyboardType="numeric"
containerStyle={s.numberInput} />
keyboardType="numeric"
containerStyle={s.numberInput} />
</View>
<TouchableOpacity onPress={showRightPart ? this._focusNumber : this._focusExpiry }>
<Image style={s.icon} source={Icons[this._iconToShow()]} />
Expand All @@ -160,21 +160,21 @@ export default class LiteCreditCardInput extends Component {
showRightPart ? s.expanded : s.hidden,
]}>
<TouchableOpacity onPress={this._focusNumber}
style={s.last4}>
style={s.last4}>
<View pointerEvents={"none"}>
<CCInput field="last4"
keyboardType="numeric"
value={ numberStatus === "valid" ? number.substr(number.length - 4, 4) : "" }
inputStyle={[s.input, inputStyle]}
containerStyle={[s.last4Input]} />
keyboardType="numeric"
value={ numberStatus === "valid" ? number.substr(number.length - 4, 4) : "" }
inputStyle={[s.input, inputStyle]}
containerStyle={[s.last4Input]} />
</View>
</TouchableOpacity>
<CCInput {...this._inputProps("expiry")}
keyboardType="numeric"
containerStyle={s.expiryInput} />
keyboardType="numeric"
containerStyle={s.expiryInput} />
<CCInput {...this._inputProps("cvc")}
keyboardType="numeric"
containerStyle={s.cvcInput} />
keyboardType="numeric"
containerStyle={s.cvcInput} />
</View>
</View>
);
Expand Down
14 changes: 7 additions & 7 deletions src/connectToState.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from "react";
import PropTypes from 'prop-types';
import PropTypes from "prop-types";
import CCFieldFormatter from "./CCFieldFormatter";
import CCFieldValidator from "./CCFieldValidator";
import compact from "lodash.compact";
Expand Down Expand Up @@ -112,12 +112,12 @@ export default function connectToState(CreditCardInput) {
render() {
return (
<CreditCardInput
{...this.props}
{...this.state}
onFocus={this._onFocus}
onChange={this._change}
onBecomeEmpty={this._focusPreviousField}
onBecomeValid={this._focusNextField} />
{...this.props}
{...this.state}
onFocus={this._onFocus}
onChange={this._change}
onBecomeEmpty={this._focusPreviousField}
onBecomeValid={this._focusNextField} />
);
}
}
Expand Down
Loading

0 comments on commit be9dfb9

Please sign in to comment.