Skip to content

Commit 614bbf7

Browse files
committed
Changed some styling, aligned the icon and text
1 parent e8465a1 commit 614bbf7

2 files changed

Lines changed: 44 additions & 24 deletions

File tree

src/Base/Base.stories.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ storiesOf('Default', module)
2727
<Input
2828
label="Username"
2929
onChangeText={text => onChangeText(text)}
30+
labelTextColor="#3B82F6"
3031
// value={value}
31-
// icon={<Text>+91</Text>}
32+
icon={<Text>+91</Text>}
33+
borderColor="#3B82F6"
34+
// color="#3B82F6"
3235
// iconPosition="left"
3336
// focusColor="#22D3EE"
3437
/>

src/Base/index.js

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

@@ -36,42 +37,58 @@ const Input = ({
3637
}
3738

3839
if (focused) {
39-
return props.focusColor || '#52525B';
40+
return props.focusColor || props.borderColor || '#52525B';
4041
}
42+
return props.borderColor;
4143
};
4244

4345
return (
4446
<>
4547
<View style={{...props.labelStyles}}>
46-
{label && <Text>{label}</Text>}
48+
{label && (
49+
<Text style={{color: props.labelTextColor || '#000'}}>{label}</Text>
50+
)}
4751
</View>
4852
<View
4953
style={{
5054
...(props.wrapperStyles || {
51-
height: 42,
52-
borderWidth: 1,
53-
borderRadius: 4,
54-
paddingHorizontal: 5,
55-
marginTop: 5,
56-
alignItems: icon ? 'center' : 'baseline',
55+
height: props.height || 42,
56+
borderWidth: props.borderWidth || 1,
57+
borderRadius: props.borderRadius || 4,
58+
paddingHorizontal: props.paddingHorizontal || 5,
59+
marginTop: props.marginTop || 5,
60+
alignItems: 'icon' ? 'center' : 'baseline',
5761
borderColor: getBorderColor(),
58-
flexDirection: getFlexDirection(),
62+
flexDirection: getFlexDirection() || 'row',
5963
}),
6064
}}>
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-
/>
65+
<View
66+
style={{
67+
flex: 1,
68+
alignItems: 'center',
69+
}}>
70+
{icon && icon}
71+
</View>
72+
<View
73+
style={{
74+
flex: 8,
75+
height: props.height || 42,
76+
}}>
77+
<TextInput
78+
placeholder={placeholder}
79+
style={textInputStyles}
80+
color={props.color || '#000'}
81+
onChangeText={onChangeText}
82+
value={value}
83+
onFocus={() => {
84+
setFocused(true);
85+
}}
86+
onBlur={() => {
87+
setFocused(false);
88+
}}
89+
{...props}
90+
/>
91+
</View>
7592
</View>
7693
<View>
7794
{error && (

0 commit comments

Comments
 (0)