Skip to content

Commit 2f3e106

Browse files
committed
Merge pull request #23 from taskrabbit/upgrade
Upgrade
2 parents 18a1e3f + 171598e commit 2f3e106

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1303
-551
lines changed

.babelrc

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,4 @@
11
{
2-
"plugins": [
3-
"syntax-async-functions",
4-
"syntax-class-properties",
5-
"syntax-trailing-function-commas",
6-
"transform-class-properties",
7-
"transform-es2015-arrow-functions",
8-
"transform-es2015-block-scoping",
9-
"transform-es2015-classes",
10-
"transform-es2015-computed-properties",
11-
"transform-es2015-constants",
12-
"transform-es2015-destructuring",
13-
["transform-es2015-modules-commonjs", {"strict": false, "allowTopLevelThis": true}],
14-
"transform-es2015-parameters",
15-
"transform-es2015-shorthand-properties",
16-
"transform-es2015-spread",
17-
"transform-es2015-template-literals",
18-
"transform-flow-strip-types",
19-
"transform-object-assign",
20-
"transform-object-rest-spread",
21-
"transform-react-display-name",
22-
"transform-react-jsx",
23-
"transform-regenerator",
24-
"transform-es2015-for-of"
25-
],
2+
"presets": ["react-native"],
3+
"plugins": ["syntax-async-functions", "transform-regenerator"]
264
}

App/Actions/AppActions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var Dispatcher = require('../Dispatcher');
2-
var AppConstants = require('../Constants/AppConstants');
3-
var assign = require('object-assign');
1+
import Dispatcher from '../Dispatcher';
2+
import AppConstants from '../Constants/AppConstants';
3+
import assign from 'object-assign';
44

55
var AppActions = {
66
appLaunched: function() {
@@ -77,4 +77,4 @@ var AppActions = {
7777

7878
};
7979

80-
module.exports = AppActions;
80+
export default AppActions;

App/Actions/AuthActions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var Dispatcher = require('../Dispatcher');
2-
var AppConstants = require('../Constants/AppConstants');
3-
var AuthService = require('../Api/AuthService');
1+
import Dispatcher from '../Dispatcher';
2+
import AppConstants from '../Constants/AppConstants';
3+
import AuthService from '../Api/AuthService';
44

55
var AuthActions = {
66
authCallback: function(callback) {
@@ -26,4 +26,4 @@ var AuthActions = {
2626
}
2727
};
2828

29-
module.exports = AuthActions;
29+
export default AuthActions;

App/Actions/FollowActions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var Dispatcher = require('../Dispatcher');
2-
var AppConstants = require('../Constants/AppConstants');
3-
var FollowService = require('../Api/FollowService');
1+
import Dispatcher from '../Dispatcher';
2+
import AppConstants from '../Constants/AppConstants';
3+
import FollowService from '../Api/FollowService';
44

55
var FollowActions = {
66

@@ -18,4 +18,4 @@ var FollowActions = {
1818
}
1919
};
2020

21-
module.exports = FollowActions;
21+
export default FollowActions;

App/Actions/PostActions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var Dispatcher = require('../Dispatcher');
2-
var AppConstants = require('../Constants/AppConstants');
3-
var PostService = require('../Api/PostService');
1+
import Dispatcher from '../Dispatcher';
2+
import AppConstants from '../Constants/AppConstants';
3+
import PostService from '../Api/PostService';
44

55
var PostActions = {
66

@@ -31,4 +31,4 @@ var PostActions = {
3131
}
3232
};
3333

34-
module.exports = PostActions;
34+
export default PostActions;

App/Api/AuthService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var client = require('../Api/HTTPClient')
1+
import client from '../Api/HTTPClient';
22

33
var UserService = {
44
parseAccount: function(response) {
@@ -29,4 +29,4 @@ var UserService = {
2929
}
3030
};
3131

32-
module.exports = UserService;
32+
export default UserService;

App/Api/FollowService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var client = require('../Api/HTTPClient')
1+
import client from '../Api/HTTPClient';
22

33
var FolllowService = {
44
parseFolllow: function(response) {
@@ -29,4 +29,4 @@ var FolllowService = {
2929
}
3030
};
3131

32-
module.exports = FolllowService;
32+
export default FolllowService;

App/Api/HTTPClient.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// http://visionmedia.github.io/superagent
2-
var superagent = require('superagent');
2+
import superagent from 'superagent';
33

4-
var Network = require('../Api/Network');
4+
import Network from '../Api/Network';
55

6-
var CurrentUserStore = require('../Stores/CurrentUserStore');
7-
var EnvironmentStore = require('../Stores/EnvironmentStore');
6+
import CurrentUserStore from '../Stores/CurrentUserStore';
7+
import EnvironmentStore from '../Stores/EnvironmentStore';
88

99
var HTTPClient = {
1010
wrapper: function(inner) {
@@ -123,4 +123,4 @@ var HTTPClient = {
123123
}
124124
};
125125

126-
module.exports = HTTPClient;
126+
export default HTTPClient;

App/Api/Network.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var Dispatcher = require('../Dispatcher');
2-
var AppConstants = require('../Constants/AppConstants');
1+
import Dispatcher from '../Dispatcher';
2+
import AppConstants from '../Constants/AppConstants';
33

44
var _httpCount = 0; // TODO: immutable?
55

@@ -35,4 +35,4 @@ var Network = {
3535
}
3636
};
3737

38-
module.exports = Network;
38+
export default Network;

App/Api/PostService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var client = require('../Api/HTTPClient')
1+
import client from '../Api/HTTPClient';
22

33
var PostService = {
44
parsePost: function(response) {
@@ -37,4 +37,4 @@ var PostService = {
3737
},
3838
};
3939

40-
module.exports = PostService;
40+
export default PostService;

App/Components/Button.js

Lines changed: 111 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,27 @@
1-
// https://github.com/ide/react-native-button
1+
import React from 'react';
2+
import {PropTypes} from 'react';
3+
import {StyleSheet, TouchableOpacity, View, PixelRatio} from 'react-native';
24

3-
var React = require('react-native');
4-
var {
5-
PropTypes,
6-
StyleSheet,
7-
TouchableOpacity,
8-
View,
9-
PixelRatio
10-
} = React;
5+
import cssVar from '../Lib/cssVar';
6+
import _ from 'underscore';
117

12-
var cssVar = require('../Lib/cssVar');
8+
import Text from '../Components/Text';
139

14-
var Text = require('../Components/Text');
1510

16-
function coalesceNonElementChildren(children, coalesceNodes) {
17-
var coalescedChildren = [];
11+
const systemButtonOpacity = 0.2;
1812

19-
var contiguousNonElements = [];
20-
React.Children.forEach(children, (child) => {
21-
if (!React.isValidElement(child)) {
22-
contiguousNonElements.push(child);
23-
return;
24-
}
25-
26-
if (contiguousNonElements.length) {
27-
var coalescedChild = coalesceNodes(contiguousNonElements, coalescedChildren.length);
28-
coalescedChildren.push(
29-
coalesceNodes(contiguousNonElements, coalescedChildren.length)
30-
);
31-
contiguousNonElements = [];
32-
}
33-
34-
coalescedChildren.push(child);
35-
});
36-
37-
if (contiguousNonElements.length) {
38-
coalescedChildren.push(
39-
coalesceNodes(contiguousNonElements, coalescedChildren.length)
40-
);
41-
}
42-
43-
return coalescedChildren;
44-
}
45-
46-
var systemButtonOpacity = 0.2;
47-
48-
var Button = React.createClass({
13+
const Button = React.createClass({
4914
propTypes: {
5015
...TouchableOpacity.propTypes,
5116
disabled: PropTypes.bool,
5217
style: Text.propTypes.style,
5318
},
5419

5520
render() {
56-
var touchableProps = {
21+
let touchableProps = {
5722
activeOpacity: this._computeActiveOpacity(),
5823
};
24+
5925
if (!this.props.disabled) {
6026
touchableProps.onPress = this.props.onPress;
6127
touchableProps.onPressIn = this.props.onPressIn;
@@ -70,14 +36,20 @@ var Button = React.createClass({
7036
);
7137
},
7238

39+
_stylesFromType(refinement) {
40+
return buttonStyles[this.props.type] && buttonStyles[this.props.type][refinement];
41+
},
42+
7343
_renderGroupedChildren() {
74-
var buttonStateStyle = this.props.disabled ? styles.disabledText : null;
44+
let disabledStateStyle = this.props.disabled ? styles.disabledText : null;
7545

76-
var children = coalesceNonElementChildren(this.props.children, (children, index) => {
46+
let children = _.flatten([this.props.children]).map((children, index) => {
7747
return (
7848
<Text
7949
key={index}
80-
style={[styles.text, buttonStateStyle, styles.button, (styles[this.props.type] || {}), this.props.style]}>
50+
allowFontScaling={false}
51+
style={[{flex: 0, paddingHorizontal: 5, textAlign: 'center'}, styles.text, disabledStateStyle, this._stylesFromType('text'), this.props.textStyle]}
52+
>
8153
{children}
8254
</Text>
8355
);
@@ -86,10 +58,8 @@ var Button = React.createClass({
8658
switch (children.length) {
8759
case 0:
8860
return null;
89-
case 1:
90-
return children[0];
9161
default:
92-
return <View style={styles.group}>{children}</View>;
62+
return <View style={[{justifyContent: 'center', alignItems: 'center'}, styles.button, this._stylesFromType('button'), this.props.style]}>{children}</View>;
9363
}
9464
},
9565

@@ -103,35 +73,107 @@ var Button = React.createClass({
10373
},
10474
});
10575

106-
var styles = StyleSheet.create({
107-
button: {
108-
padding: 15
109-
},
76+
const buttonStyles = {
11077
blue: {
111-
backgroundColor: cssVar('blue50')
78+
button: {
79+
backgroundColor: cssVar('blue50'),
80+
},
81+
text: {
82+
color: 'white',
83+
},
11284
},
113-
transparent: {
114-
backgroundColor: 'transparent',
115-
borderWidth: 1 / PixelRatio.get(),
116-
borderColor: 'white',
85+
86+
secondary: {
87+
button: {
88+
backgroundColor: 'white',
89+
borderColor: cssVar('blue50'),
90+
},
91+
text: {
92+
color: cssVar('blue50'),
93+
},
11794
},
95+
96+
link: {
97+
text: {
98+
textDecorationLine: 'underline',
99+
color: cssVar('gray50'),
100+
},
101+
},
102+
103+
square: {
104+
button: {
105+
borderRadius: 0,
106+
},
107+
},
108+
118109
icon: {
119-
fontFamily: cssVar('fontIcon')
110+
text: {
111+
fontFamily: cssVar('fontIcon'),
112+
},
113+
button: {
114+
borderRadius: 0,
115+
padding: 5,
116+
margin: 0,
117+
flex: 0,
118+
},
120119
},
120+
121+
autoWidth: {
122+
button: {
123+
flex: 0,
124+
},
125+
},
126+
127+
transparent: {
128+
button: {
129+
backgroundColor: 'transparent',
130+
borderColor: 'white',
131+
},
132+
},
133+
134+
transparentBlue: {
135+
button: {
136+
backgroundColor: 'transparent',
137+
borderColor: cssVar('blue50'),
138+
},
139+
text: {
140+
color: cssVar('blue50'),
141+
},
142+
},
143+
144+
transparentGray: {
145+
button: {
146+
backgroundColor: 'transparent',
147+
borderColor: cssVar('gray50'),
148+
},
149+
text: {
150+
color: cssVar('gray50'),
151+
},
152+
},
153+
154+
};
155+
156+
const styles = StyleSheet.create({
157+
158+
button: {
159+
padding: 15,
160+
borderRadius: 1.5 * PixelRatio.get(),
161+
borderWidth: 1 / PixelRatio.get(),
162+
borderColor: 'transparent',
163+
flex: 1,
164+
flexDirection: 'row',
165+
alignItems: 'center',
166+
},
167+
121168
text: {
122169
color: 'white',
123-
fontSize: 17,
124-
fontWeight: 'bold',
125-
textAlign: 'center',
170+
fontFamily: cssVar('fontRegular'),
171+
fontSize: 18,
126172
},
173+
127174
disabledText: {
128175
color: '#dcdcdc',
129176
},
130-
group: {
131-
flexDirection: 'row',
132-
justifyContent: 'space-between',
133-
alignItems: 'center',
134-
},
135177
});
136178

137-
module.exports = Button;
179+
export default Button;

0 commit comments

Comments
 (0)