@bigbinary/neetoui-rn 0.0.125 → 0.0.128
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/assets/fonts/SFProText-Bold.ttf +0 -0
- package/assets/fonts/SFProText-Medium.ttf +0 -0
- package/assets/fonts/SFProText-Regular.ttf +0 -0
- package/assets/fonts/SFProText-Semibold.ttf +0 -0
- package/assets/icons/apple-logo.svg +3 -0
- package/assets/icons/error.svg +4 -0
- package/assets/icons/google-logo.svg +6 -0
- package/assets/icons/info.svg +7 -0
- package/assets/icons/success.svg +3 -0
- package/assets/icons/warning.svg +5 -0
- package/lib/components/Alert.js +1 -1
- package/lib/components/Avatar.js +1 -1
- package/lib/components/Badge.js +1 -1
- package/lib/components/BottomSheet.js +1 -1
- package/lib/components/Button.js +1 -1
- package/lib/components/Carousel.js +1 -0
- package/lib/components/CheckBox.js +1 -1
- package/lib/components/Chip.js +1 -1
- package/lib/components/Input.js +1 -1
- package/lib/components/ListItem.js +1 -0
- package/lib/components/MultiSelect.js +1 -1
- package/lib/components/OnBoarding.js +1 -0
- package/lib/components/OtpInputs.js +1 -1
- package/lib/components/Popover.js +1 -1
- package/lib/components/RadioButton.js +1 -1
- package/lib/components/SearchBar.js +1 -0
- package/lib/components/SegmentPicker.js +1 -0
- package/lib/components/Select.js +1 -1
- package/lib/components/SocialButton.js +1 -0
- package/lib/components/Toast.js +1 -1
- package/lib/components/ToggleSwitch.js +1 -1
- package/lib/components/index.js +1 -1
- package/lib/config/toasterConfig.js +1 -1
- package/lib/hooks/index.js +1 -1
- package/lib/hooks/useDebounce.js +1 -0
- package/lib/theme/index.js +1 -1
- package/package.json +5 -3
- package/src/components/Alert.js +5 -5
- package/src/components/Avatar.js +1 -1
- package/src/components/Badge.js +1 -1
- package/src/components/BottomSheet.js +113 -74
- package/src/components/Button.js +152 -61
- package/src/components/Carousel.js +112 -0
- package/src/components/CheckBox.js +87 -81
- package/src/components/Chip.js +1 -1
- package/src/components/Input.js +147 -241
- package/src/components/ListItem.js +66 -0
- package/src/components/MultiSelect.js +6 -6
- package/src/components/OnBoarding.js +116 -0
- package/src/components/OtpInputs.js +1 -1
- package/src/components/Popover.js +13 -1
- package/src/components/RadioButton.js +88 -114
- package/src/components/SearchBar.js +134 -0
- package/src/components/SegmentPicker.js +210 -0
- package/src/components/Select.js +5 -5
- package/src/components/SocialButton.js +89 -0
- package/src/components/Toast.js +85 -30
- package/src/components/ToggleSwitch.js +49 -97
- package/src/components/Typography.js +2 -2
- package/src/components/index.js +6 -0
- package/src/config/toasterConfig.js +2 -2
- package/src/hooks/index.js +1 -0
- package/src/hooks/useDebounce.js +16 -0
- package/src/theme/index.js +68 -34
- package/assets/fonts/Inter-Bold.ttf +0 -0
- package/assets/fonts/Inter-Regular.ttf +0 -0
package/src/components/Button.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
2
|
import propTypes from "@styled-system/prop-types";
|
|
3
|
-
import { Typography, Container, Touchable } from "@components";
|
|
4
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import { ThemeContext } from "styled-components/native";
|
|
5
|
+
import { ActivityIndicator } from "react-native";
|
|
6
|
+
|
|
7
|
+
import { Typography, Touchable } from "@components";
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
*
|
|
8
11
|
* Buttons are touchable elements used to interact with the screen and to trigger an action.
|
|
9
12
|
*
|
|
10
13
|
* <div class="screenshots">
|
|
11
|
-
* <img src="screenshots/button/
|
|
12
|
-
* <img src="screenshots/button/loaderButtons.png" />
|
|
14
|
+
* <img src="screenshots/button/button.png" />
|
|
13
15
|
* </div>
|
|
14
16
|
*
|
|
15
17
|
* ## Usage
|
|
@@ -20,13 +22,35 @@ import PropTypes from "prop-types";
|
|
|
20
22
|
* export default function Main() {
|
|
21
23
|
* return (
|
|
22
24
|
* <Container>
|
|
25
|
+
* <Button my={9} label="Button1" />
|
|
26
|
+
* <Button my={9} disabled label="Disabled Button2" />
|
|
27
|
+
* <Button
|
|
28
|
+
* my={9}
|
|
29
|
+
* LeftIcon={() => <Icon name="ri-add-line" color="white" size={16} />}
|
|
30
|
+
* label="Left Icon Button"
|
|
31
|
+
* />
|
|
23
32
|
* <Button
|
|
24
33
|
* my={9}
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
34
|
+
* RightIcon={() => <Icon name="ri-add-line" color="white" size={16} />}
|
|
35
|
+
* label="Right Icon Button"
|
|
36
|
+
* />
|
|
37
|
+
* <Button my={9} variant="text" label="Text Button" />
|
|
38
|
+
* <Button
|
|
39
|
+
* my={9}
|
|
40
|
+
* variant="text"
|
|
41
|
+
* LeftIcon={() => (
|
|
42
|
+
* <Icon name="ri-add-line" color={theme.fonts.primary} size={16} />
|
|
43
|
+
* )}
|
|
44
|
+
* label="Left Icon Text Button"
|
|
45
|
+
* />
|
|
46
|
+
* <Button
|
|
47
|
+
* my={9}
|
|
48
|
+
* variant="text"
|
|
49
|
+
* RightIcon={() => (
|
|
50
|
+
* <Icon name="ri-add-line" color={theme.fonts.primary} size={16} />
|
|
51
|
+
* )}
|
|
52
|
+
* label="Right Icon Text Button"
|
|
53
|
+
* />
|
|
30
54
|
* </Container>
|
|
31
55
|
* );
|
|
32
56
|
* }
|
|
@@ -34,63 +58,125 @@ import PropTypes from "prop-types";
|
|
|
34
58
|
*
|
|
35
59
|
*/
|
|
36
60
|
|
|
37
|
-
export const Button =
|
|
61
|
+
export const Button = props => {
|
|
38
62
|
const {
|
|
63
|
+
variant,
|
|
64
|
+
label,
|
|
65
|
+
labelStyle,
|
|
39
66
|
RightIcon,
|
|
40
67
|
LeftIcon,
|
|
41
|
-
fontFamily,
|
|
42
|
-
color,
|
|
43
|
-
fontSize,
|
|
44
|
-
loadingText,
|
|
45
|
-
isLoading,
|
|
46
|
-
Loader,
|
|
47
68
|
disabled,
|
|
48
|
-
|
|
69
|
+
isLoading,
|
|
49
70
|
...rest
|
|
50
71
|
} = props;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
72
|
+
const theme = useContext(ThemeContext);
|
|
73
|
+
const width = variant === "text" || variant === "danger-text" ? null : "100%";
|
|
74
|
+
|
|
75
|
+
const getButtonColors = () => {
|
|
76
|
+
switch (variant) {
|
|
77
|
+
case "solid":
|
|
78
|
+
return {
|
|
79
|
+
bg: theme.colors.background[disabled ? "grey400" : "base"],
|
|
80
|
+
border: theme.colors.background[disabled ? "grey400" : "base"],
|
|
81
|
+
color: theme.colors.background.white,
|
|
82
|
+
ripple: "white",
|
|
83
|
+
};
|
|
84
|
+
case "text":
|
|
85
|
+
return {
|
|
86
|
+
bg: "transparent",
|
|
87
|
+
border: "transparent",
|
|
88
|
+
color: theme.colors.font.primary,
|
|
89
|
+
ripple: "black",
|
|
90
|
+
};
|
|
91
|
+
case "danger":
|
|
92
|
+
return {
|
|
93
|
+
bg: theme.colors.background.danger,
|
|
94
|
+
border: theme.colors.background.danger,
|
|
95
|
+
color: theme.colors.background.white,
|
|
96
|
+
ripple: "white",
|
|
97
|
+
};
|
|
98
|
+
case "danger-inverse":
|
|
99
|
+
return {
|
|
100
|
+
bg: theme.colors.background.white,
|
|
101
|
+
border: theme.colors.background.danger,
|
|
102
|
+
color: theme.colors.background.danger,
|
|
103
|
+
ripple: "black",
|
|
104
|
+
};
|
|
105
|
+
case "danger-text":
|
|
106
|
+
return {
|
|
107
|
+
bg: "transparent",
|
|
108
|
+
border: "transparent",
|
|
109
|
+
color: theme.colors.background.danger,
|
|
110
|
+
ripple: "black",
|
|
111
|
+
};
|
|
112
|
+
default:
|
|
113
|
+
return {
|
|
114
|
+
bg: theme.colors.background[disabled ? "grey400" : "base"],
|
|
115
|
+
border: theme.colors.background[disabled ? "grey400" : "base"],
|
|
116
|
+
color: theme.colors.background.white,
|
|
117
|
+
ripple: "white",
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const renderOpacity = () => {
|
|
123
|
+
if (
|
|
124
|
+
["danger", "danger-inverse", "danger-text"].includes(variant) &&
|
|
125
|
+
disabled
|
|
126
|
+
)
|
|
127
|
+
return 0.5;
|
|
128
|
+
return 1;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const renderLoaderColor = () => {
|
|
132
|
+
if (["text", "danger", "danger-inverse", "danger-text"].includes(variant))
|
|
133
|
+
return "base";
|
|
134
|
+
return "white";
|
|
135
|
+
};
|
|
55
136
|
|
|
56
137
|
return (
|
|
57
138
|
<Touchable
|
|
58
|
-
{
|
|
59
|
-
|
|
139
|
+
rippleColor={getButtonColors().ripple}
|
|
140
|
+
disabled={disabled}
|
|
141
|
+
bg={getButtonColors().bg}
|
|
142
|
+
height={45}
|
|
143
|
+
width={width}
|
|
144
|
+
borderRadius={8}
|
|
60
145
|
flexDirection="row"
|
|
61
|
-
|
|
146
|
+
alignItems="center"
|
|
147
|
+
justifyContent="center"
|
|
148
|
+
borderColor={getButtonColors().border}
|
|
149
|
+
borderWidth={1}
|
|
150
|
+
opacity={renderOpacity()}
|
|
62
151
|
{...rest}
|
|
63
|
-
variant={variant}
|
|
64
|
-
style={style}
|
|
65
152
|
>
|
|
66
|
-
{
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
153
|
+
{isLoading ? (
|
|
154
|
+
<ActivityIndicator
|
|
155
|
+
color={theme.colors.background[renderLoaderColor()]}
|
|
156
|
+
/>
|
|
157
|
+
) : (
|
|
158
|
+
<>
|
|
159
|
+
{LeftIcon && <LeftIcon />}
|
|
160
|
+
<Typography
|
|
161
|
+
textAlign="center"
|
|
162
|
+
mx={2}
|
|
163
|
+
color={getButtonColors().color}
|
|
164
|
+
fontSize="m"
|
|
165
|
+
fontFamily={theme.fonts.sf500}
|
|
166
|
+
{...labelStyle}
|
|
167
|
+
>
|
|
168
|
+
{label}
|
|
169
|
+
</Typography>
|
|
170
|
+
{RightIcon && <RightIcon />}
|
|
171
|
+
</>
|
|
70
172
|
)}
|
|
71
|
-
{LeftIcon && <LeftIcon />}
|
|
72
|
-
<Typography
|
|
73
|
-
textAlign="center"
|
|
74
|
-
mx={1}
|
|
75
|
-
color={color}
|
|
76
|
-
fontFamily={fontFamily || "inter700"}
|
|
77
|
-
fontSize={fontSize || "s"}
|
|
78
|
-
textStyle={variant}
|
|
79
|
-
>
|
|
80
|
-
{isLoading ? loadingText : rest.label}
|
|
81
|
-
</Typography>
|
|
82
|
-
{RightIcon && <RightIcon />}
|
|
83
173
|
</Touchable>
|
|
84
174
|
);
|
|
85
|
-
}
|
|
175
|
+
};
|
|
86
176
|
|
|
87
177
|
Button.defaultProps = {
|
|
88
178
|
variant: "solid",
|
|
89
|
-
|
|
90
|
-
alignItems: "center",
|
|
91
|
-
justifyContent: "center",
|
|
92
|
-
borderRadius: 2,
|
|
93
|
-
loadingText: "Loading…",
|
|
179
|
+
isLoading: false,
|
|
94
180
|
};
|
|
95
181
|
|
|
96
182
|
Button.propTypes = {
|
|
@@ -105,33 +191,38 @@ Button.propTypes = {
|
|
|
105
191
|
*/
|
|
106
192
|
label: PropTypes.string.isRequired,
|
|
107
193
|
/**
|
|
108
|
-
* Supported Type: 'text' | '
|
|
194
|
+
* Supported Type: 'text' | 'solid'
|
|
109
195
|
* You can change the mode to adjust the styling.
|
|
110
196
|
* <ul>
|
|
111
197
|
* <li>text - flat button without background or outline.</li>
|
|
112
|
-
* <li>inverse - button with an outline.</li>
|
|
113
198
|
* <li>solid - button with a background color.</li>
|
|
114
199
|
* </ul>
|
|
115
200
|
*/
|
|
116
|
-
variant: PropTypes.oneOf([
|
|
201
|
+
variant: PropTypes.oneOf([
|
|
202
|
+
"text",
|
|
203
|
+
"solid",
|
|
204
|
+
"danger",
|
|
205
|
+
"danger-inverse",
|
|
206
|
+
"danger-text",
|
|
207
|
+
]),
|
|
117
208
|
/**
|
|
118
|
-
*
|
|
209
|
+
* Enable or Disable the button.
|
|
119
210
|
*/
|
|
120
|
-
|
|
211
|
+
disabled: PropTypes.bool,
|
|
121
212
|
/**
|
|
122
|
-
*
|
|
213
|
+
* Customize label style of the button.
|
|
123
214
|
*/
|
|
124
|
-
|
|
215
|
+
labelStyle: PropTypes.object,
|
|
125
216
|
/**
|
|
126
|
-
*
|
|
217
|
+
* Render a component on the right side of the Label.
|
|
127
218
|
*/
|
|
128
|
-
|
|
219
|
+
RightIcon: PropTypes.elementType,
|
|
129
220
|
/**
|
|
130
|
-
*
|
|
221
|
+
* Render a component on the left side of the Label.
|
|
131
222
|
*/
|
|
132
|
-
|
|
223
|
+
LeftIcon: PropTypes.elementType,
|
|
133
224
|
/**
|
|
134
|
-
*
|
|
225
|
+
* To show loading indicator on the button.
|
|
135
226
|
*/
|
|
136
|
-
|
|
227
|
+
isLoading: PropTypes.bool,
|
|
137
228
|
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { StyleSheet, Dimensions, useWindowDimensions } from "react-native";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import CarouselParent, { Pagination } from "react-native-snap-carousel";
|
|
5
|
+
|
|
6
|
+
import { Container } from "@components";
|
|
7
|
+
|
|
8
|
+
const { width } = Dimensions.get("screen");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* <div class="screenshots">
|
|
13
|
+
* <img src="screenshots/carousel/carousel.png" />
|
|
14
|
+
* </div>
|
|
15
|
+
*
|
|
16
|
+
* This component supports below props categories from [styled-system ](/styled-system).
|
|
17
|
+
* <ul>
|
|
18
|
+
* <li>flexbox</li>
|
|
19
|
+
* <li>space</li>
|
|
20
|
+
* <li>border</li>
|
|
21
|
+
* <li>layout</li>
|
|
22
|
+
* <li>color</li>
|
|
23
|
+
* <li>buttonStyle</li>
|
|
24
|
+
* </ul>
|
|
25
|
+
*
|
|
26
|
+
* ## Usage
|
|
27
|
+
* ```js
|
|
28
|
+
* import * as React from "react";
|
|
29
|
+
* import { Carousel } from "@bigbinary/neetoui-rn";
|
|
30
|
+
*
|
|
31
|
+
* export default function Main() {
|
|
32
|
+
*
|
|
33
|
+
* return (
|
|
34
|
+
* <Carousel itemArray={[{url:"https://picsum.photos/200"}]} />
|
|
35
|
+
* );
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
export const Carousel = ({
|
|
42
|
+
itemArray,
|
|
43
|
+
renderItem,
|
|
44
|
+
carouselRef,
|
|
45
|
+
onSnapToItem,
|
|
46
|
+
}) => {
|
|
47
|
+
const { width } = useWindowDimensions();
|
|
48
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Container>
|
|
52
|
+
<CarouselParent
|
|
53
|
+
ref={carouselRef}
|
|
54
|
+
data={itemArray}
|
|
55
|
+
renderItem={renderItem}
|
|
56
|
+
sliderWidth={width}
|
|
57
|
+
itemWidth={width}
|
|
58
|
+
onSnapToItem={index => {
|
|
59
|
+
onSnapToItem(index);
|
|
60
|
+
setActiveIndex(index);
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
63
|
+
|
|
64
|
+
<Pagination
|
|
65
|
+
dotsLength={itemArray.length}
|
|
66
|
+
activeDotIndex={activeIndex}
|
|
67
|
+
dotStyle={styles.dotStyle}
|
|
68
|
+
inactiveDotStyle={styles.inactiveDotStyle}
|
|
69
|
+
inactiveDotOpacity={0.4}
|
|
70
|
+
inactiveDotScale={0.6}
|
|
71
|
+
dotContainerStyle={styles.dotContainerStyle}
|
|
72
|
+
/>
|
|
73
|
+
</Container>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const styles = StyleSheet.create({
|
|
78
|
+
image: {
|
|
79
|
+
height: width / 1.8,
|
|
80
|
+
width: width / 1.8,
|
|
81
|
+
resizeMode: "contain",
|
|
82
|
+
borderRadius: 20,
|
|
83
|
+
},
|
|
84
|
+
indicator: {
|
|
85
|
+
height: 12,
|
|
86
|
+
width: 12,
|
|
87
|
+
borderRadius: 10,
|
|
88
|
+
marginVertical: 20,
|
|
89
|
+
marginHorizontal: 5,
|
|
90
|
+
backgroundColor: "#49545C",
|
|
91
|
+
borderColor: "#FFFFFF",
|
|
92
|
+
borderWidth: 2,
|
|
93
|
+
},
|
|
94
|
+
dotStyle: {
|
|
95
|
+
width: 10,
|
|
96
|
+
height: 10,
|
|
97
|
+
borderRadius: 5,
|
|
98
|
+
marginHorizontal: 8,
|
|
99
|
+
backgroundColor: "#2F3941",
|
|
100
|
+
},
|
|
101
|
+
inactiveDotStyle: {
|
|
102
|
+
backgroundColor: "#D9D9D9",
|
|
103
|
+
},
|
|
104
|
+
dotContainerStyle: { marginHorizontal: 0 },
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
Carousel.propTypes = {
|
|
108
|
+
itemArray: PropTypes.array.isRequired,
|
|
109
|
+
renderItem: PropTypes.func.isRequired,
|
|
110
|
+
onSnapToItem: PropTypes.func,
|
|
111
|
+
carouselRef: PropTypes.object,
|
|
112
|
+
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
2
|
import Proptypes from "prop-types";
|
|
3
|
+
import Icon from "react-native-remix-icon";
|
|
4
|
+
import { ThemeContext } from "styled-components/native";
|
|
3
5
|
|
|
4
6
|
import { Container, Typography, Touchable } from "@components";
|
|
5
7
|
|
|
6
|
-
const labelPositions = ["left", "right"];
|
|
7
|
-
|
|
8
|
-
const LabelComponent = ({ label, labelComponent, labelProp }) => {
|
|
9
|
-
return labelComponent || <Typography {...labelProp}>{label}</Typography>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
8
|
/**
|
|
9
|
+
*
|
|
10
|
+
* <div class="screenshots">
|
|
11
|
+
* <img src="screenshots/checkbox/checkbox.png" />
|
|
12
|
+
* </div>
|
|
13
13
|
*
|
|
14
14
|
* This component supports below props categories from [styled-system ](/styled-system).
|
|
15
15
|
* <ul>
|
|
@@ -24,24 +24,26 @@ const LabelComponent = ({ label, labelComponent, labelProp }) => {
|
|
|
24
24
|
* ## Usage
|
|
25
25
|
* ```js
|
|
26
26
|
* import * as React from "react";
|
|
27
|
-
* import { Container, CheckBox
|
|
27
|
+
* import { Container, CheckBox } from "@bigbinary/neetoui-rn";
|
|
28
28
|
*
|
|
29
29
|
* export default function Main() {
|
|
30
|
-
* const [
|
|
31
|
-
*
|
|
30
|
+
* const [checked, setChecked] = useState(true);
|
|
32
31
|
*
|
|
33
32
|
* return (
|
|
34
33
|
* <Container>
|
|
35
|
-
* <
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
34
|
+
* <CheckBox
|
|
35
|
+
* mt={2}
|
|
36
|
+
* checked={checked1}
|
|
37
|
+
* onSelect={() => setChecked1(prev => !prev)}
|
|
38
|
+
* label={`Checkbox marked as ${!checked1 ? "un" : ""}checked`}
|
|
39
|
+
* />
|
|
40
|
+
* <CheckBox
|
|
41
|
+
* mt={3}
|
|
42
|
+
* checked={checked2}
|
|
43
|
+
* onSelect={() => setChecked2(prev => !prev)}
|
|
44
|
+
* label={`Checkbox marked as ${!checked2 ? "un" : ""}checked`}
|
|
45
|
+
* />
|
|
46
|
+
* <CheckBox mt={3} disabled label="Disabled checkbox" />
|
|
45
47
|
* </Container>
|
|
46
48
|
* );
|
|
47
49
|
* }
|
|
@@ -50,68 +52,85 @@ const LabelComponent = ({ label, labelComponent, labelProp }) => {
|
|
|
50
52
|
*/
|
|
51
53
|
|
|
52
54
|
export const CheckBox = ({
|
|
53
|
-
|
|
54
|
-
onSelect
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
labelProp = {},
|
|
61
|
-
labelPosition = "right",
|
|
62
|
-
checkboxContainerProp = {},
|
|
55
|
+
checked,
|
|
56
|
+
onSelect,
|
|
57
|
+
disabled,
|
|
58
|
+
label,
|
|
59
|
+
checkboxStyle,
|
|
60
|
+
checkIconStyle,
|
|
61
|
+
labelStyle,
|
|
63
62
|
...rest
|
|
64
63
|
}) => {
|
|
64
|
+
const theme = useContext(ThemeContext);
|
|
65
|
+
const disabledProps = {
|
|
66
|
+
bg: theme.colors.background[checked ? "grey400" : "white"],
|
|
67
|
+
labelProps: {
|
|
68
|
+
color: theme.colors.font.grey400,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
const checkedProps = {
|
|
72
|
+
bg: theme.colors.background.base,
|
|
73
|
+
labelProps: {
|
|
74
|
+
fontFamily: theme.fonts.sf500,
|
|
75
|
+
color: theme.colors.font.primary,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
const unCheckedProps = {
|
|
79
|
+
bg: theme.colors.background.white,
|
|
80
|
+
borderWidth: 1,
|
|
81
|
+
borderColor: theme.colors.border.secondary,
|
|
82
|
+
labelProps: {
|
|
83
|
+
fontFamily: theme.fonts.sf400,
|
|
84
|
+
color: theme.colors.font.secondary,
|
|
85
|
+
},
|
|
86
|
+
};
|
|
65
87
|
return (
|
|
66
88
|
<Touchable
|
|
67
89
|
disabled={disabled}
|
|
68
90
|
onPress={onSelect}
|
|
69
|
-
opacity={disabled ? 0.5 : 1}
|
|
70
91
|
flexDirection="row"
|
|
71
92
|
alignItems="center"
|
|
72
93
|
{...rest}
|
|
73
94
|
>
|
|
74
|
-
{labelPosition === labelPositions[0] ? (
|
|
75
|
-
<LabelComponent
|
|
76
|
-
label={label}
|
|
77
|
-
labelComponent={labelComponent}
|
|
78
|
-
labelProp={{ mr: 2, ...labelProp }}
|
|
79
|
-
/>
|
|
80
|
-
) : null}
|
|
81
95
|
<Container
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
borderRadius={
|
|
96
|
+
height={16}
|
|
97
|
+
width={16}
|
|
98
|
+
borderRadius={3}
|
|
85
99
|
justifyContent="center"
|
|
86
100
|
alignItems="center"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
{...
|
|
101
|
+
{...(!checked && unCheckedProps)}
|
|
102
|
+
{...(checked && checkedProps)}
|
|
103
|
+
{...(disabled && disabledProps)}
|
|
104
|
+
{...checkboxStyle}
|
|
90
105
|
>
|
|
91
|
-
{
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
{checked && (
|
|
107
|
+
<Icon
|
|
108
|
+
name="ri-check-line"
|
|
109
|
+
size={14}
|
|
110
|
+
color={theme.colors.font.white}
|
|
111
|
+
{...checkIconStyle}
|
|
112
|
+
/>
|
|
97
113
|
)}
|
|
98
114
|
</Container>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
115
|
+
<Typography
|
|
116
|
+
ml={2}
|
|
117
|
+
fontSize="m"
|
|
118
|
+
{...(checked && checkedProps.labelProps)}
|
|
119
|
+
{...(!checked && unCheckedProps.labelProps)}
|
|
120
|
+
{...(disabled && disabledProps.labelProps)}
|
|
121
|
+
{...labelStyle}
|
|
122
|
+
>
|
|
123
|
+
{label}
|
|
124
|
+
</Typography>
|
|
106
125
|
</Touchable>
|
|
107
126
|
);
|
|
108
127
|
};
|
|
109
128
|
|
|
110
129
|
CheckBox.propTypes = {
|
|
111
130
|
/**
|
|
112
|
-
* Whether checkbox is
|
|
131
|
+
* Whether checkbox is checked or not.
|
|
113
132
|
*/
|
|
114
|
-
|
|
133
|
+
checked: Proptypes.bool.isRequired,
|
|
115
134
|
/**
|
|
116
135
|
* Function to execute on press.
|
|
117
136
|
*/
|
|
@@ -120,38 +139,25 @@ CheckBox.propTypes = {
|
|
|
120
139
|
* To disable the component.
|
|
121
140
|
*/
|
|
122
141
|
disabled: Proptypes.bool,
|
|
123
|
-
/**
|
|
124
|
-
* Render custom checked component.
|
|
125
|
-
*/
|
|
126
|
-
checkedComponent: Proptypes.element,
|
|
127
|
-
/**
|
|
128
|
-
* Check mark style.
|
|
129
|
-
*/
|
|
130
|
-
checkedItemProp: Proptypes.object,
|
|
131
142
|
/**
|
|
132
143
|
* Text label to be shown with radio button.
|
|
133
144
|
*/
|
|
134
145
|
label: Proptypes.string,
|
|
135
146
|
/**
|
|
136
|
-
*
|
|
147
|
+
* Customize checkbox style.
|
|
137
148
|
*/
|
|
138
|
-
|
|
149
|
+
checkboxStyle: Proptypes.object,
|
|
139
150
|
/**
|
|
140
|
-
*
|
|
151
|
+
* Customize check icon style.
|
|
141
152
|
*/
|
|
142
|
-
|
|
153
|
+
checkIconStyle: Proptypes.object,
|
|
143
154
|
/**
|
|
144
|
-
*
|
|
155
|
+
* Customize label style.
|
|
145
156
|
*/
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Extra param to customize checkbox container
|
|
149
|
-
*/
|
|
150
|
-
checkboxContainerProp: Proptypes.object,
|
|
157
|
+
labelStyle: Proptypes.object,
|
|
151
158
|
};
|
|
152
159
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
labelProp: Proptypes.object,
|
|
160
|
+
CheckBox.defaultProps = {
|
|
161
|
+
checked: false,
|
|
162
|
+
onSelect: () => {},
|
|
157
163
|
};
|
package/src/components/Chip.js
CHANGED