Skip to content

Commit

Permalink
fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabramov committed May 10, 2016
1 parent 6596d21 commit 473547d
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 53 deletions.
5 changes: 0 additions & 5 deletions .eslintignore
@@ -1,8 +1,3 @@
browser_bundle.js
browser_entry_point.js
esfmt_bundle.js
tmp/
__tests__/files/
__tests__/code_snippets/
coverage/
package/
3 changes: 2 additions & 1 deletion .eslintrc.js
Expand Up @@ -15,7 +15,8 @@ module.exports = {
semi: [
2,
'always'
]
],
'react/prop-types': [0]
},
env: {
es6: true,
Expand Down
57 changes: 28 additions & 29 deletions CalendarPicker/CalendarPicker.js
Expand Up @@ -4,47 +4,47 @@
*/
'use strict';

import React, { Component } from 'react';
import React from 'react';
import {
Dimensions,
StyleSheet,
View,
Text,
TouchableOpacity,
TouchableOpacity
} from 'react-native';

var {
WEEKDAYS,
MONTHS,
MAX_ROWS,
MAX_COLUMNS,
getDaysInMonth,
getDaysInMonth
} = require('./Util');

var makeStyles = require('./makeStyles');

//The styles in makeStyles are intially scaled to this width
const IPHONE6_WIDTH = 375
const IPHONE6_WIDTH = 375;
var initialScale = Dimensions.get('window').width / IPHONE6_WIDTH ;
var styles = StyleSheet.create(makeStyles(initialScale))
var styles = StyleSheet.create(makeStyles(initialScale));

var Day = React.createClass({
propTypes: {
onDayChange: React.PropTypes.func,
selected: React.PropTypes.bool,
day: React.PropTypes.oneOfType([
React.PropTypes.number,
React.PropTypes.string
React.PropTypes.number,
React.PropTypes.string
]).isRequired,
screenWidth: React.PropTypes.number,
startFromMonday: React.PropTypes.bool,
selectedDayColor: React.PropTypes.string,
selectedDayTextColor: React.PropTypes.string,
selectedDayTextColor: React.PropTypes.string
},
getDefaultProps () {
return {
onDayChange () {}
}
};
},

getInitialState () {
Expand All @@ -56,8 +56,8 @@ var Day = React.createClass({

render() {
if (this.props.selected) {
var selectedDayColorStyle = this.props.selectedDayColor ? {backgroundColor: this.props.selectedDayColor} : {}
var selectedDayTextColorStyle = this.props.selectedDayTextColor ? {color: this.props.selectedDayTextColor} : {}
var selectedDayColorStyle = this.props.selectedDayColor ? {backgroundColor: this.props.selectedDayColor} : {};
var selectedDayTextColorStyle = this.props.selectedDayTextColor ? {color: this.props.selectedDayTextColor} : {};
return (
<View style={styles.dayWrapper}>
<View style={[styles.dayButtonSelected, selectedDayColorStyle]}>
Expand Down Expand Up @@ -94,11 +94,11 @@ var Days = React.createClass({
year: React.PropTypes.number.isRequired,
onDayChange: React.PropTypes.func.isRequired,
selectedDayColor: React.PropTypes.string,
selectedDayTextColor: React.PropTypes.string,
selectedDayTextColor: React.PropTypes.string
},
getInitialState() {
return {
selectedStates: [],
selectedStates: []
};
},

Expand All @@ -120,7 +120,7 @@ var Days = React.createClass({
}

this.setState({
selectedStates: selectedStates,
selectedStates: selectedStates
});

},
Expand All @@ -143,8 +143,7 @@ var Days = React.createClass({
year = this.props.year,
currentDay = 0,
thisMonthFirstDay = this.props.startFromMonday ? new Date(year, month, 0) : new Date(year, month, 1),
slotsAccumulator = 0,
slotsAccumulatorOffset = this.props.startFromMonday ? 1 : 0;
slotsAccumulator = 0;

for (i = 0; i < MAX_ROWS; i++ ) { // Week rows
columns = [];
Expand All @@ -164,7 +163,7 @@ var Days = React.createClass({
currentDay++;
}
} else {
columns.push(<Day
columns.push(<Day
key={j}
day={''}
screenWidth={this.props.screenWidth}/>);
Expand Down Expand Up @@ -196,7 +195,7 @@ var WeekDaysLabels = React.createClass({
render() {
return (
<View style={styles.dayLabelsWrapper}>
{ (this.props.weekdays || WEEKDAYS).map((day, key) => { return <Text key={key} style={styles.dayLabels}>{day}</Text> }) }
{ (this.props.weekdays || WEEKDAYS).map((day, key) => { return <Text key={key} style={styles.dayLabels}>{day}</Text>; }) }
</View>
);
}
Expand Down Expand Up @@ -279,43 +278,43 @@ var CalendarPicker = React.createClass({
nextTitle: React.PropTypes.string,
selectedDayColor: React.PropTypes.string,
selectedDayTextColor: React.PropTypes.string,
scaleFactor: React.PropTypes.number,
scaleFactor: React.PropTypes.number
},
getDefaultProps() {
return {
onDateChange () {}
}
};
},
getInitialState() {
if (this.props.scaleFactor !== undefined) {
styles = StyleSheet.create(makeStyles(this.props.scaleFactor))
styles = StyleSheet.create(makeStyles(this.props.scaleFactor));
}
return {
date: this.props.selectedDate,
day: this.props.selectedDate.getDate(),
month: this.props.selectedDate.getMonth(),
year: this.props.selectedDate.getFullYear(),
selectedDay: [],
selectedDay: []
};
},

onDayChange(day) {
this.setState({day: day.day,});
this.setState({day: day.day});
this.onDateChange();
},

onMonthChange(month) {
this.setState({month: month,});
this.setState({month: month});
this.onDateChange();
},

getNextYear(){
this.setState({year: this.state.year + 1,});
this.setState({year: this.state.year + 1});
this.onDateChange();
},

getPrevYear() {
this.setState({year: this.state.year - 1,});
this.setState({year: this.state.year - 1});
this.onDateChange();
},

Expand All @@ -327,8 +326,8 @@ var CalendarPicker = React.createClass({
} = this.state,
date = new Date(year, month, day);

this.setState({date: date,});
this.props.onDateChange(date);
this.setState({date: date});
this.props.onDateChange(date);
},

render() {
Expand Down Expand Up @@ -364,4 +363,4 @@ var CalendarPicker = React.createClass({
}
});

module.exports = CalendarPicker;
module.exports = CalendarPicker;
6 changes: 3 additions & 3 deletions CalendarPicker/Styles.js
Expand Up @@ -19,7 +19,7 @@ var styles = StyleSheet.create({
dayButton: {
flex: 1,
justifyContent: 'center',
alignSelf: 'center',
alignSelf: 'center'
},

dayLabel: {
Expand All @@ -41,11 +41,11 @@ var styles = StyleSheet.create({
},

daysWrapper: {
alignSelf: 'center',
alignSelf: 'center'
},

dayLabels: {
textAlign: 'center',
textAlign: 'center'
},

monthLabel: {
Expand Down
2 changes: 1 addition & 1 deletion CalendarPicker/Util.js
Expand Up @@ -17,5 +17,5 @@ module.exports = {
getDaysInMonth: function(month, year) {
var lastDayOfMonth = new Date(year, month + 1, 0);
return lastDayOfMonth.getDate();
},
}
};
14 changes: 7 additions & 7 deletions CalendarPicker/makeStyles.js
Expand Up @@ -50,14 +50,14 @@ function makeStyles(scaler) {
},

daysWrapper: {
alignSelf: 'center',
alignSelf: 'center'
},

dayLabels: {
width: 50*scaler,
fontSize: 10*scaler,
color: '#000',
textAlign: 'center',
textAlign: 'center'
},

selectedDay: {
Expand Down Expand Up @@ -86,17 +86,17 @@ function makeStyles(scaler) {
},

monthSelector: {
width: 80*scaler,
width: 80*scaler
},

prev: {
textAlign: 'left',
fontSize: 14*scaler,
fontSize: 14*scaler
},

next: {
textAlign: 'right',
fontSize: 14*scaler,
fontSize: 14*scaler
},

yearLabel: {
Expand All @@ -113,8 +113,8 @@ function makeStyles(scaler) {
weekRow: {
flexDirection: 'row'
}
}
};
}


module.exports = makeStyles
module.exports = makeStyles;
14 changes: 7 additions & 7 deletions index.ios.js
Expand Up @@ -4,7 +4,7 @@
*/
'use strict';

import React, { Component } from 'react';
import React from 'react';
import {
AppRegistry,
Dimensions,
Expand All @@ -14,13 +14,13 @@ import {
} from 'react-native';

var CalendarPicker = require('./CalendarPicker/CalendarPicker'),
CalendarPicker2;
CalendarPicker2;


CalendarPicker2 = React.createClass({
getInitialState: function() {
return {
date: new Date(),
date: new Date()
};
},

Expand All @@ -36,8 +36,8 @@ CalendarPicker2 = React.createClass({
selectedDate={this.state.date}
onDateChange={this.onDateChange}
screenWidth={Dimensions.width}
weekdays = {["Mon", "Tue", "Wed", "Th", "Fri", "Sat", "Sun"]}
months = {["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]}
weekdays = {['Mon', 'Tue', 'Wed', 'Th', 'Fri', 'Sat', 'Sun']}
months = {['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']}
nextTitle={'Next'}
previousTitle={'Previous'}
startFromMonday={true}
Expand All @@ -54,11 +54,11 @@ CalendarPicker2 = React.createClass({

const styles = StyleSheet.create({
container: {
marginTop: 30,
marginTop: 30
},
selectedDate: {
backgroundColor: 'rgba(0,0,0,0)',
color: '#000',
color: '#000'
}
});

Expand Down

0 comments on commit 473547d

Please sign in to comment.