Skip to content

Commit 163f984

Browse files
committed
import all the things
1 parent 5929efb commit 163f984

Some content is hidden

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

60 files changed

+360
-308
lines changed

App/Actions/AppActions.js

Lines changed: 3 additions & 3 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() {

App/Actions/AuthActions.js

Lines changed: 3 additions & 3 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) {

App/Actions/FollowActions.js

Lines changed: 3 additions & 3 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

App/Actions/PostActions.js

Lines changed: 3 additions & 3 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

App/Api/AuthService.js

Lines changed: 1 addition & 1 deletion
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) {

App/Api/FollowService.js

Lines changed: 1 addition & 1 deletion
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) {

App/Api/HTTPClient.js

Lines changed: 4 additions & 4 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) {

App/Api/Network.js

Lines changed: 2 additions & 2 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

App/Api/PostService.js

Lines changed: 1 addition & 1 deletion
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) {

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;

App/Components/SegmentedControl.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// https://github.com/ide/react-native-button
22

3-
var React = require('react-native');
4-
var {
3+
import React from 'react';
4+
import {
55
StyleSheet,
66
TouchableHighlight,
77
View
8-
} = React;
8+
} from 'react-native';
99

10-
var cssVar = require('../Lib/cssVar');
11-
var Text = require('../Components/Text');
12-
var AppActions = require('../Actions/AppActions');
10+
import cssVar from '../Lib/cssVar';
11+
import Text from '../Components/Text';
12+
import AppActions from '../Actions/AppActions';
1313

1414
var SegmentedControl = React.createClass({
1515
segmentComponents: function() {

App/Components/SimpleList.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
var React = require('react-native');
2-
var {
1+
import React from 'react';
2+
import {
33
ListView
4-
} = React;
4+
} from 'react-native';
55

6-
var RefreshableListView = require('react-native-refreshable-listview');
6+
import RefreshableListView from 'react-native-refreshable-listview';
77

8-
var SimpleListItem = require('../Components/SimpleListItem');
8+
import SimpleListItem from '../Components/SimpleListItem';
99

1010
var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
1111

App/Components/SimpleListItem.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
var React = require('react-native');
2-
var {
1+
import React from 'react';
2+
import {
33
View,
44
StyleSheet,
55
TouchableHighlight
6-
} = React;
6+
} from 'react-native';
77

8-
var cssVar = require('../Lib/cssVar');
8+
import cssVar from '../Lib/cssVar';
99

10-
var Text = require('../Components/Text');
11-
var AppActions = require('../Actions/AppActions');
10+
import Text from '../Components/Text';
11+
import AppActions from '../Actions/AppActions';
1212

1313
var SimpleListItem = React.createClass({
1414
onSelection: function() {

0 commit comments

Comments
 (0)