Skip to content

Commit 4e18dde

Browse files
authored
Dev (#5)
* DEV: fix prop types for components that have prop types children * 0.0.5 * 0.0.6 * 0.0.7 * DEV: using eslint from expo + cleanup * 0.0.8 * DEV: added Utils, components prop types fix * 0.0.9 * DEV: component fix import constants from Utils * 0.0.10 * DEV: Utils fix import all constants as variable * 0.0.11 * DEV: Button fix title prop types * 0.0.12 * DEV: Block fix for flex as number * 0.0.13 * DEV: Block fix flex as bool or number * 0.0.14 * DEV: readme updates + textStyle for button * DEV: components small updates
1 parent 6df4797 commit 4e18dde

16 files changed

+384
-245
lines changed

.eslintrc

+2-35
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,3 @@
11
{
2-
"parser": "babel-eslint",
3-
"extends": "airbnb",
4-
"plugins": [
5-
"react",
6-
"react-native",
7-
"flowtype",
8-
"jsx-a11y",
9-
"import"
10-
],
11-
"rules": {
12-
"react/jsx-filename-extension": [
13-
1, { "extensions": [".js", ".jsx"] }
14-
],
15-
"react/prefer-stateless-function": [
16-
2, { "ignorePureComponents": true }
17-
],
18-
"import/extensions": [1, "never", { "svg": "always" }],
19-
"import/no-extraneous-dependencies": [
20-
"error",
21-
{
22-
"devDependencies": true,
23-
"optionalDependencies": false,
24-
"peerDependencies": false
25-
}
26-
],
27-
"semi": ["error", "never"],
28-
"no-use-before-define": 0,
29-
},
30-
"env": {
31-
"node": true,
32-
"browser": true,
33-
"es6": true,
34-
"jest": true
35-
},
36-
}
2+
extends: 'universe',
3+
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ yarn-debug.log*
88
yarn-error.log*
99
yarn.lock
1010
.DS_Store
11+
CNAME

README.md

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
11
# React Native UI Kit
22
React Native components based on React UI Kit
33

4-
Components list:
4+
Components:
55
- buttons:
6-
- Button
7-
- Link
6+
- [x] Button
7+
- [x] Link
8+
- [ ] Upload
89
- inputs:
9-
- Input
10-
- Select
10+
- [x] Input
11+
- [x] Select
12+
- [ ] Checkbox
13+
- [ ] Datepiker
14+
- [ ] Progress
1115
- views:
12-
- Block
13-
- Container
14-
- Text
16+
- [x] Block
17+
- [x] Container
18+
- [x] Text
19+
- [ ] List
20+
- [ ] Menu
21+
- [ ] Tabs
22+
- [ ] Badge
23+
- [ ] Label
24+
25+
Examples screens:
26+
- [ ] Login
27+
- [ ] Forgot
28+
- [ ] Register / Signup
29+
- [ ] Profile
30+
- [ ] Camera
31+
32+
### To do
33+
[ ] export component styles as `componentStyle` and import
34+
35+
### Requests
36+
Have an idea for a new component or Screen? Just contact us at [email protected] and will add it to our list.

components/buttons/Button.js

+40-47
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,46 @@
1-
import React from 'react'
2-
import { Text, TouchableOpacity, StyleSheet } from 'react-native'
3-
import PropTypes from 'prop-types'
1+
import React from 'react';
2+
// eslint-disable-next-line
3+
import { Text, TouchableOpacity, View, StyleSheet } from 'react-native';
4+
import PropTypes from 'prop-types';
45

5-
import * as specs from '../../constants'
6+
import * as specs from '../../utils/constants';
67

78
class Button extends React.Component {
89
renderContent = () => {
9-
const {
10-
color, label, title, basic, inverted, size, bold, icon,
11-
} = this.props
12-
const text = label || title || null
13-
const textStyle = [
14-
basic ? styles.basicText : null,
15-
bold ? { fontWeight: 'bold' } : null,
10+
const { color, label, title, basic, inverted, size, bold, icon, textStyle } = this.props;
11+
const text = label || title || null;
12+
const textStyles = [
13+
basic && styles.basicText,
14+
bold && { fontWeight: 'bold' },
15+
inverted && styles.basicText,
16+
textStyle && { ...textStyle },
1617
color ? { color } : { color: specs.COLOR_WHITE },
17-
inverted ? styles.basicText : null,
1818
size ? { fontSize: size } : { fontSize: specs.BUTTON_FONT_SIZE },
19-
]
19+
];
2020

21-
if (icon && !text) return icon
21+
if (icon && !text) return icon;
2222

23-
return (
24-
<Text style={textStyle}>
25-
{text}
26-
</Text>
27-
)
28-
}
23+
return <Text style={textStyles}>{text}</Text>;
24+
};
2925

3026
render() {
31-
const {
32-
color, label, title, disabled, basic, inverted, border, full, style, ...props
33-
} = this.props
27+
const { disabled, basic, inverted, border, full, style, ...props } = this.props;
3428

3529
const buttonStyle = [
3630
styles.button,
37-
basic ? styles.basic : null,
38-
inverted ? styles.inverted : null,
39-
border ? styles.border : null,
40-
full ? styles.full : null,
41-
disabled ? styles.disabled : null,
31+
basic && styles.basic,
32+
inverted && styles.inverted,
33+
border && styles.border,
34+
full && styles.full,
35+
disabled && styles.disabled,
4236
style,
43-
]
37+
];
4438

4539
return (
4640
<TouchableOpacity {...props} disabled={disabled} style={buttonStyle}>
4741
{this.renderContent()}
4842
</TouchableOpacity>
49-
)
43+
);
5044
}
5145
}
5246

@@ -59,28 +53,29 @@ Button.propTypes = {
5953
full: PropTypes.bool,
6054
icon: PropTypes.bool,
6155
inverted: PropTypes.bool,
62-
label: PropTypes.bool,
56+
label: PropTypes.string,
6357
size: PropTypes.number,
64-
style: TouchableOpacity.propTypes.style,
65-
title: PropTypes.bool,
66-
}
58+
style: View.propTypes.style,
59+
textStyle: Text.propTypes.style,
60+
title: PropTypes.string,
61+
};
6762

6863
Button.defaultProps = {
6964
basic: false,
7065
bold: false,
7166
border: false,
7267
disabled: false,
73-
color: specs.COLOR_WHITE,
68+
color: specs.COLOR_PRIMARY,
7469
full: false,
75-
icon: false,
70+
icon: null,
7671
inverted: false,
77-
label: false,
78-
size: 0,
72+
label: null,
73+
size: specs.FONT_SIZE,
7974
style: {},
80-
title: false,
81-
}
75+
title: null,
76+
};
8277

83-
export default Button
78+
export default Button;
8479

8580
const styles = StyleSheet.create({
8681
button: {
@@ -89,8 +84,6 @@ const styles = StyleSheet.create({
8984
borderRadius: specs.BUTTON_RADIUS,
9085
height: specs.BUTTON_HEIGHT,
9186
justifyContent: 'center',
92-
marginBottom: specs.MARGIN,
93-
marginTop: specs.MARGIN,
9487
padding: specs.BUTTON_PADDING,
9588
width: specs.WIDTH * 0.5, // 50%
9689
},
@@ -101,11 +94,11 @@ const styles = StyleSheet.create({
10194
},
10295
inverted: {
10396
backgroundColor: specs.COLOR_WHITE,
104-
borderColor: specs.COLOR_ACCENT,
97+
borderColor: specs.COLOR_PRIMARY,
10598
borderWidth: 0.5,
10699
},
107100
border: {
108-
borderColor: specs.COLOR_ACCENT,
101+
borderColor: specs.COLOR_PRIMARY,
109102
borderWidth: 0.5,
110103
},
111104
disabled: {
@@ -115,6 +108,6 @@ const styles = StyleSheet.create({
115108
width: specs.WIDTH * 0.8, // 80%
116109
},
117110
basicText: {
118-
color: specs.COLOR_ACCENT,
111+
color: specs.COLOR_PRIMARY,
119112
},
120-
})
113+
});

components/buttons/Link.js

+15-21
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
1-
import React from 'react'
2-
import { Linking, Text, StyleSheet } from 'react-native'
3-
import PropTypes from 'prop-types'
1+
import React from 'react';
2+
import { Linking, Text, StyleSheet } from 'react-native';
3+
import PropTypes from 'prop-types';
44

5-
import * as specs from '../../constants'
5+
import * as specs from '../../utils/constants';
66

77
class Link extends React.Component {
88
navigateURL = () => {
9-
const { href, onPress } = this.props
9+
const { href, onPress } = this.props;
1010

11-
Linking.openURL(href)
12-
onPress()
13-
}
11+
Linking.openURL(href);
12+
onPress();
13+
};
1414

1515
render() {
16-
const {
17-
style, color, onPress, ...props
18-
} = this.props
16+
const { style, color, ...props } = this.props;
1917

2018
return (
21-
<Text
22-
onPress={this.navigateURL}
23-
style={[styles.link, { color }, style]}
24-
{...props}
25-
>
19+
<Text {...props} onPress={this.navigateURL} style={[styles.link, { color }, style]}>
2620
{props.children}
2721
</Text>
28-
)
22+
);
2923
}
3024
}
3125

@@ -34,20 +28,20 @@ Link.propTypes = {
3428
href: PropTypes.string,
3529
onPress: PropTypes.func,
3630
style: Text.propTypes.style,
37-
}
31+
};
3832

3933
Link.defaultProps = {
4034
color: specs.LINK_COLOR,
4135
href: 'null',
4236
onPress: () => {},
4337
style: {},
44-
}
38+
};
4539

46-
export default Link
40+
export default Link;
4741

4842
const styles = StyleSheet.create({
4943
link: {
5044
height: specs.BUTTON_HEIGHT,
5145
paddingVertical: specs.BUTTON_PADDING,
5246
},
53-
})
47+
});

components/inputs/Input.js

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import React from 'react'
2-
import { TextInput, StyleSheet } from 'react-native'
3-
import PropTypes from 'prop-types'
1+
import React from 'react';
2+
import { TextInput, StyleSheet } from 'react-native';
3+
import PropTypes from 'prop-types';
44

5-
import * as specs from '../../constants'
5+
import * as specs from '../../utils/constants';
66

77
class Input extends React.PureComponent {
88
render() {
9-
const {
10-
style, placeholderTextColor, multiline, ...rest
11-
} = this.props
9+
const { style, placeholderTextColor, multiline, ...rest } = this.props;
1210

1311
if (multiline) {
1412
return (
@@ -19,7 +17,7 @@ class Input extends React.PureComponent {
1917
style={[styles.input, { height: 'auto' }, style]}
2018
underlineColorAndroid="transparent"
2119
/>
22-
)
20+
);
2321
}
2422

2523
return (
@@ -29,23 +27,23 @@ class Input extends React.PureComponent {
2927
placeholderTextColor={placeholderTextColor}
3028
underlineColorAndroid="transparent"
3129
/>
32-
)
30+
);
3331
}
3432
}
3533

3634
Input.propTypes = {
3735
placeholderTextColor: PropTypes.string,
3836
multiline: PropTypes.bool,
3937
style: TextInput.propTypes.style,
40-
}
38+
};
4139

4240
Input.defaultProps = {
4341
placeholderTextColor: specs.PLACEHOLDER_COLOR,
4442
multiline: false,
4543
style: {},
46-
}
44+
};
4745

48-
export default Input
46+
export default Input;
4947

5048
const styles = StyleSheet.create({
5149
input: {
@@ -62,4 +60,4 @@ const styles = StyleSheet.create({
6260
textShadowColor: 'transparent',
6361
width: specs.WIDTH * 0.8, // 80%
6462
},
65-
})
63+
});

0 commit comments

Comments
 (0)