@bigbinary/neetoui-rn 0.0.17 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Button.js +53 -9
- package/lib/components/Input.js +172 -0
- package/lib/components/index.js +1 -0
- package/lib/theme/index.js +20 -8
- package/package.json +1 -1
package/lib/components/Button.js
CHANGED
|
@@ -1,30 +1,74 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
flexbox,
|
|
4
|
+
space,
|
|
5
|
+
border,
|
|
6
|
+
buttonStyle,
|
|
7
|
+
color,
|
|
8
|
+
layout,
|
|
9
|
+
} from "styled-system";
|
|
3
10
|
import styled from "styled-components/native";
|
|
4
11
|
import propTypes from "@styled-system/prop-types";
|
|
5
|
-
import
|
|
12
|
+
import { Typography } from "@components";
|
|
6
13
|
|
|
7
14
|
export const TouchableOpacity = styled.TouchableOpacity`
|
|
15
|
+
${buttonStyle}
|
|
8
16
|
${flexbox}
|
|
9
17
|
${space}
|
|
10
18
|
${border}
|
|
11
|
-
${
|
|
19
|
+
${layout}
|
|
20
|
+
${color}
|
|
12
21
|
`;
|
|
13
22
|
|
|
14
|
-
export const Button = ({
|
|
15
|
-
|
|
23
|
+
export const Button = ({
|
|
24
|
+
RightIcon,
|
|
25
|
+
LeftIcon,
|
|
26
|
+
fontFamily,
|
|
27
|
+
color,
|
|
28
|
+
fontSize,
|
|
29
|
+
...rest
|
|
30
|
+
}) => {
|
|
31
|
+
const { disabled } = rest;
|
|
32
|
+
let style = rest.style || {};
|
|
33
|
+
if (disabled) {
|
|
34
|
+
style = { ...style, opacity: 0.5 };
|
|
35
|
+
}
|
|
36
|
+
return (
|
|
37
|
+
<TouchableOpacity
|
|
38
|
+
flexDirection="row"
|
|
39
|
+
disabled={disabled}
|
|
40
|
+
{...rest}
|
|
41
|
+
style={style}
|
|
42
|
+
>
|
|
43
|
+
{RightIcon && <RightIcon />}
|
|
44
|
+
<Typography
|
|
45
|
+
textAlign="center"
|
|
46
|
+
mx={1}
|
|
47
|
+
color={color}
|
|
48
|
+
fontFamily={fontFamily || "inter700"}
|
|
49
|
+
fontSize={fontSize || "s"}
|
|
50
|
+
textStyle={rest.variant}
|
|
51
|
+
>
|
|
52
|
+
{rest.label}
|
|
53
|
+
</Typography>
|
|
54
|
+
{LeftIcon && <LeftIcon />}
|
|
55
|
+
</TouchableOpacity>
|
|
56
|
+
);
|
|
16
57
|
};
|
|
17
58
|
|
|
18
59
|
Button.defaultProps = {
|
|
19
|
-
variant: "
|
|
20
|
-
p:
|
|
60
|
+
variant: "solid",
|
|
61
|
+
p: 12,
|
|
21
62
|
alignItems: "center",
|
|
63
|
+
justifyContent: "center",
|
|
64
|
+
borderRadius: 2,
|
|
22
65
|
};
|
|
23
66
|
|
|
24
67
|
Button.propTypes = {
|
|
68
|
+
...propTypes.buttonStyle,
|
|
25
69
|
...propTypes.flexbox,
|
|
26
70
|
...propTypes.space,
|
|
27
71
|
...propTypes.border,
|
|
28
|
-
...propTypes.
|
|
29
|
-
|
|
72
|
+
...propTypes.layout,
|
|
73
|
+
...propTypes.color,
|
|
30
74
|
};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import React, { useContext, useState } from "react";
|
|
2
|
+
import { flexbox, space, border, buttonStyle, typography } from "styled-system";
|
|
3
|
+
import styled, { ThemeContext } from "styled-components/native";
|
|
4
|
+
import propTypes from "@styled-system/prop-types";
|
|
5
|
+
import PropTypes from "prop-types";
|
|
6
|
+
import { Typography, Container } from "@components";
|
|
7
|
+
|
|
8
|
+
export const TextInput = styled.TextInput`
|
|
9
|
+
${flexbox}
|
|
10
|
+
${space}
|
|
11
|
+
${border}
|
|
12
|
+
${buttonStyle}
|
|
13
|
+
${typography}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const InputText = ({ theme, text }) => (
|
|
17
|
+
<Container
|
|
18
|
+
bg={theme.colors.background.menubackground}
|
|
19
|
+
justifyContent="center"
|
|
20
|
+
px={2}
|
|
21
|
+
>
|
|
22
|
+
<Typography>{text}</Typography>
|
|
23
|
+
</Container>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const LabelText = ({ inline, label }) => (
|
|
27
|
+
<Typography
|
|
28
|
+
numberOfLines={1}
|
|
29
|
+
textStyle="subtext"
|
|
30
|
+
mb={inline ? "12px" : "7px"}
|
|
31
|
+
>
|
|
32
|
+
{label}
|
|
33
|
+
</Typography>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const ErrorMessage = ({ error, message, theme }) => {
|
|
37
|
+
if (error) {
|
|
38
|
+
return (
|
|
39
|
+
<Typography textStyle="subtext" color={theme.colors.font.danger}>
|
|
40
|
+
{message}
|
|
41
|
+
</Typography>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Input = ({
|
|
48
|
+
label = "",
|
|
49
|
+
message = "",
|
|
50
|
+
error = false,
|
|
51
|
+
onFocus,
|
|
52
|
+
onBlur,
|
|
53
|
+
inline = false,
|
|
54
|
+
brandRight,
|
|
55
|
+
brandLeft,
|
|
56
|
+
disabled = false,
|
|
57
|
+
...rest
|
|
58
|
+
}) => {
|
|
59
|
+
const theme = useContext(ThemeContext);
|
|
60
|
+
const [isFocus, setIsFocus] = useState(false);
|
|
61
|
+
const borderColor = error
|
|
62
|
+
? theme.colors.border.danger
|
|
63
|
+
: theme.colors.border.primary;
|
|
64
|
+
|
|
65
|
+
const handleFocus = e => {
|
|
66
|
+
onFocus && onFocus(e);
|
|
67
|
+
setIsFocus(true);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const handleBlur = e => {
|
|
71
|
+
onBlur && onBlur(e);
|
|
72
|
+
setIsFocus(false);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const focusStyles = isFocus && {
|
|
76
|
+
borderRadius: 4,
|
|
77
|
+
borderColor: error
|
|
78
|
+
? "rgba(255, 105, 105, 0.3)"
|
|
79
|
+
: theme.colors.border.grey400,
|
|
80
|
+
borderWidth: inline ? "0px" : "3px",
|
|
81
|
+
borderStyle: "solid",
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const disabledStyles = disabled && {
|
|
85
|
+
opacity: 0.5,
|
|
86
|
+
bg: theme.colors.background.secondary,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const inlineInputStyles = isFocus && {
|
|
90
|
+
backgroundColor: error
|
|
91
|
+
? theme.colors.border.danger
|
|
92
|
+
: theme.colors.border.base,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<Container mb={20}>
|
|
97
|
+
{!inline && <LabelText inline={inline} label={label} />}
|
|
98
|
+
<Container
|
|
99
|
+
{...focusStyles}
|
|
100
|
+
{...disabledStyles}
|
|
101
|
+
flexDirection={inline && "row"}
|
|
102
|
+
onBlur={handleBlur}
|
|
103
|
+
onFocus={handleFocus}
|
|
104
|
+
>
|
|
105
|
+
{inline && (
|
|
106
|
+
<Container alignSelf="flex-end" maxWidth={100} px={2}>
|
|
107
|
+
<LabelText inline={inline} label={label} />
|
|
108
|
+
</Container>
|
|
109
|
+
)}
|
|
110
|
+
<Container flexDirection="row" width="100%">
|
|
111
|
+
{brandLeft && <InputText theme={theme} text={brandLeft} />}
|
|
112
|
+
<TextInput
|
|
113
|
+
height={40}
|
|
114
|
+
flex={1}
|
|
115
|
+
textStyle="subtext"
|
|
116
|
+
{...rest}
|
|
117
|
+
border={!inline && borderColor}
|
|
118
|
+
editable={!disabled}
|
|
119
|
+
color={error ? theme.colors.font.danger : theme.colors.font.primary}
|
|
120
|
+
/>
|
|
121
|
+
{brandRight && <InputText theme={theme} text={brandRight} />}
|
|
122
|
+
</Container>
|
|
123
|
+
</Container>
|
|
124
|
+
{inline && (
|
|
125
|
+
<Container
|
|
126
|
+
backgroundColor={theme.colors.border.primary}
|
|
127
|
+
height={1}
|
|
128
|
+
{...inlineInputStyles}
|
|
129
|
+
/>
|
|
130
|
+
)}
|
|
131
|
+
<ErrorMessage theme={theme} error={error} message={message} />
|
|
132
|
+
</Container>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
Input.propTypes = {
|
|
137
|
+
...propTypes.flexbox,
|
|
138
|
+
...propTypes.space,
|
|
139
|
+
...propTypes.border,
|
|
140
|
+
...propTypes.buttonStyle,
|
|
141
|
+
label: PropTypes.string.isRequired,
|
|
142
|
+
message: PropTypes.string,
|
|
143
|
+
error: PropTypes.bool,
|
|
144
|
+
inline: PropTypes.bool,
|
|
145
|
+
brandRight: PropTypes.string,
|
|
146
|
+
brandLeft: PropTypes.string,
|
|
147
|
+
disabled: PropTypes.bool,
|
|
148
|
+
children: PropTypes.node,
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
InputText.propTypes = {
|
|
152
|
+
text: PropTypes.string,
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
LabelText.propTypes = {
|
|
156
|
+
inline: PropTypes.bool,
|
|
157
|
+
label: PropTypes.string,
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
ErrorMessage.propTypes = {
|
|
161
|
+
error: PropTypes.bool,
|
|
162
|
+
message: PropTypes.message,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
TextInput.defaultProps = {
|
|
166
|
+
height: 40,
|
|
167
|
+
border: 1,
|
|
168
|
+
px: 2,
|
|
169
|
+
fontFamily: "inter400",
|
|
170
|
+
fontSize: "14px",
|
|
171
|
+
borderRadius: 2,
|
|
172
|
+
};
|
package/lib/components/index.js
CHANGED
package/lib/theme/index.js
CHANGED
|
@@ -3,6 +3,7 @@ const defaultColors = {
|
|
|
3
3
|
black: "#000000",
|
|
4
4
|
base: "#2f3941",
|
|
5
5
|
danger: "#ff6969",
|
|
6
|
+
menubackground: "#f4f5f7",
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
const greyVarients = {
|
|
@@ -86,19 +87,30 @@ export const theme = {
|
|
|
86
87
|
color: baseTheme.colors.font.primary,
|
|
87
88
|
fontSize: baseTheme.fontSizes.s,
|
|
88
89
|
},
|
|
90
|
+
|
|
91
|
+
// buttonTextStyles
|
|
92
|
+
solid: {
|
|
93
|
+
color: baseTheme.colors.font.white,
|
|
94
|
+
},
|
|
95
|
+
inverse: {
|
|
96
|
+
color: baseTheme.colors.font.base,
|
|
97
|
+
},
|
|
98
|
+
text: {
|
|
99
|
+
color: baseTheme.colors.font.base,
|
|
100
|
+
},
|
|
89
101
|
},
|
|
90
102
|
buttons: {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
backgroundColor: baseTheme.colors.grey800,
|
|
103
|
+
solid: {
|
|
104
|
+
backgroundColor: baseTheme.colors.background.base,
|
|
94
105
|
},
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
inverse: {
|
|
107
|
+
border: 2,
|
|
108
|
+
borderColor: baseTheme.colors.white,
|
|
97
109
|
backgroundColor: baseTheme.colors.white,
|
|
98
110
|
},
|
|
99
|
-
|
|
100
|
-
color:
|
|
101
|
-
backgroundColor: baseTheme.colors.
|
|
111
|
+
text: {
|
|
112
|
+
color: baseTheme.colors.grey800,
|
|
113
|
+
backgroundColor: baseTheme.colors.white,
|
|
102
114
|
},
|
|
103
115
|
},
|
|
104
116
|
};
|