Skip to content

Commit ae2584f

Browse files
authored
Merge pull request #2 from Dhruv-Rathi/master
Changed some styling, aligned the icon and text
2 parents e8465a1 + 525b9d7 commit ae2584f

2 files changed

Lines changed: 43 additions & 27 deletions

File tree

src/Base/Base.stories.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ storiesOf('Default', module)
2727
<Input
2828
label="Username"
2929
onChangeText={text => onChangeText(text)}
30+
labelTextColor="#3B82F6"
3031
// value={value}
3132
// icon={<Text>+91</Text>}
33+
borderColor="#3B82F6"
34+
// color="#3B82F6"
3235
// iconPosition="left"
33-
// focusColor="#22D3EE"
36+
// focusBorderColor="#22D3EE"
3437
/>
3538
))
3639
.add('Default Required Field', () => (

src/Base/index.js

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {height} from 'dom-helpers';
12
import React from 'react';
23
import {Text, View, TextInput} from 'react-native';
34

@@ -33,45 +34,57 @@ const Input = ({
3334
const getBorderColor = () => {
3435
if (error) {
3536
return props.borderColor || '#DC2626';
37+
} else if (focused) {
38+
return props.focusBorderColor || props.borderColor;
3639
}
37-
38-
if (focused) {
39-
return props.focusColor || '#52525B';
40-
}
40+
return props.borderColor;
4141
};
4242

4343
return (
4444
<>
4545
<View style={{...props.labelStyles}}>
46-
{label && <Text>{label}</Text>}
46+
{label && (
47+
<Text style={{color: props.labelTextColor || '#000'}}>{label}</Text>
48+
)}
4749
</View>
4850
<View
4951
style={{
5052
...(props.wrapperStyles || {
51-
height: 42,
52-
borderWidth: 1,
53-
borderRadius: 4,
54-
paddingHorizontal: 5,
55-
marginTop: 5,
56-
alignItems: icon ? 'center' : 'baseline',
53+
height: props.height || 42,
54+
borderWidth: props.borderWidth || 1,
55+
borderRadius: props.borderRadius || 4,
56+
paddingHorizontal: props.paddingHorizontal || 5,
57+
marginTop: props.marginTop || 5,
58+
alignItems: 'center',
5759
borderColor: getBorderColor(),
58-
flexDirection: getFlexDirection(),
60+
flexDirection: getFlexDirection() || 'row',
5961
}),
6062
}}>
61-
<View>{icon && icon}</View>
62-
<TextInput
63-
placeholder={placeholder}
64-
style={textInputStyles}
65-
onChangeText={onChangeText}
66-
value={value}
67-
onFocus={() => {
68-
setFocused(true);
69-
}}
70-
onBlur={() => {
71-
setFocused(false);
72-
}}
73-
{...props}
74-
/>
63+
<View
64+
style={{
65+
alignItems: 'center',
66+
}}>
67+
{icon && icon}
68+
</View>
69+
<View
70+
style={{
71+
height: props.height || 42,
72+
}}>
73+
<TextInput
74+
placeholder={placeholder}
75+
style={textInputStyles}
76+
color={props.color || '#000'}
77+
onChangeText={onChangeText}
78+
value={value}
79+
onFocus={() => {
80+
setFocused(true);
81+
}}
82+
onBlur={() => {
83+
setFocused(false);
84+
}}
85+
{...props}
86+
/>
87+
</View>
7588
</View>
7689
<View>
7790
{error && (

0 commit comments

Comments
 (0)