@bigbinary/neetoui-rn 0.0.125 → 0.0.126

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.
Files changed (66) hide show
  1. package/assets/fonts/SFProText-Bold.ttf +0 -0
  2. package/assets/fonts/SFProText-Medium.ttf +0 -0
  3. package/assets/fonts/SFProText-Regular.ttf +0 -0
  4. package/assets/fonts/SFProText-Semibold.ttf +0 -0
  5. package/assets/icons/apple-logo.svg +3 -0
  6. package/assets/icons/error.svg +4 -0
  7. package/assets/icons/google-logo.svg +6 -0
  8. package/assets/icons/info.svg +7 -0
  9. package/assets/icons/success.svg +3 -0
  10. package/assets/icons/warning.svg +5 -0
  11. package/lib/components/Alert.js +1 -1
  12. package/lib/components/Avatar.js +1 -1
  13. package/lib/components/Badge.js +1 -1
  14. package/lib/components/BottomSheet.js +1 -1
  15. package/lib/components/Button.js +1 -1
  16. package/lib/components/Carousel.js +1 -0
  17. package/lib/components/CheckBox.js +1 -1
  18. package/lib/components/Chip.js +1 -1
  19. package/lib/components/Input.js +1 -1
  20. package/lib/components/ListItem.js +1 -0
  21. package/lib/components/MultiSelect.js +1 -1
  22. package/lib/components/OnBoarding.js +1 -0
  23. package/lib/components/OtpInputs.js +1 -1
  24. package/lib/components/Popover.js +1 -1
  25. package/lib/components/RadioButton.js +1 -1
  26. package/lib/components/SearchBar.js +1 -0
  27. package/lib/components/SegmentPicker.js +1 -0
  28. package/lib/components/Select.js +1 -1
  29. package/lib/components/SocialButton.js +1 -0
  30. package/lib/components/Toast.js +1 -1
  31. package/lib/components/ToggleSwitch.js +1 -1
  32. package/lib/components/index.js +1 -1
  33. package/lib/config/toasterConfig.js +1 -1
  34. package/lib/hooks/index.js +1 -1
  35. package/lib/hooks/useDebounce.js +1 -0
  36. package/lib/theme/index.js +1 -1
  37. package/package.json +5 -3
  38. package/src/components/Alert.js +5 -5
  39. package/src/components/Avatar.js +1 -1
  40. package/src/components/Badge.js +1 -1
  41. package/src/components/BottomSheet.js +114 -74
  42. package/src/components/Button.js +66 -64
  43. package/src/components/Carousel.js +112 -0
  44. package/src/components/CheckBox.js +87 -81
  45. package/src/components/Chip.js +1 -1
  46. package/src/components/Input.js +147 -241
  47. package/src/components/ListItem.js +59 -0
  48. package/src/components/MultiSelect.js +6 -6
  49. package/src/components/OnBoarding.js +116 -0
  50. package/src/components/OtpInputs.js +1 -1
  51. package/src/components/Popover.js +13 -1
  52. package/src/components/RadioButton.js +88 -114
  53. package/src/components/SearchBar.js +134 -0
  54. package/src/components/SegmentPicker.js +210 -0
  55. package/src/components/Select.js +5 -5
  56. package/src/components/SocialButton.js +89 -0
  57. package/src/components/Toast.js +85 -30
  58. package/src/components/ToggleSwitch.js +49 -97
  59. package/src/components/Typography.js +2 -2
  60. package/src/components/index.js +6 -0
  61. package/src/config/toasterConfig.js +2 -2
  62. package/src/hooks/index.js +1 -0
  63. package/src/hooks/useDebounce.js +16 -0
  64. package/src/theme/index.js +65 -34
  65. package/assets/fonts/Inter-Bold.ttf +0 -0
  66. package/assets/fonts/Inter-Regular.ttf +0 -0
@@ -1,15 +1,16 @@
1
- import * as React from "react";
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
+
6
+ import { Typography, Touchable } from "@components";
5
7
 
6
8
  /**
7
9
  *
8
10
  * Buttons are touchable elements used to interact with the screen and to trigger an action.
9
11
  *
10
12
  * <div class="screenshots">
11
- * <img src="screenshots/button/solidButtons.png" />
12
- * <img src="screenshots/button/loaderButtons.png" />
13
+ * <img src="screenshots/button/button.png" />
13
14
  * </div>
14
15
  *
15
16
  * ## Usage
@@ -20,13 +21,35 @@ import PropTypes from "prop-types";
20
21
  * export default function Main() {
21
22
  * return (
22
23
  * <Container>
24
+ * <Button my={9} label="Button1" />
25
+ * <Button my={9} disabled label="Disabled Button2" />
26
+ * <Button
27
+ * my={9}
28
+ * LeftIcon={() => <Icon name="ri-add-line" color="white" size={16} />}
29
+ * label="Left Icon Button"
30
+ * />
31
+ * <Button
32
+ * my={9}
33
+ * RightIcon={() => <Icon name="ri-add-line" color="white" size={16} />}
34
+ * label="Right Icon Button"
35
+ * />
36
+ * <Button my={9} variant="text" label="Text Button" />
37
+ * <Button
38
+ * my={9}
39
+ * variant="text"
40
+ * LeftIcon={() => (
41
+ * <Icon name="ri-add-line" color={theme.fonts.primary} size={16} />
42
+ * )}
43
+ * label="Left Icon Text Button"
44
+ * />
23
45
  * <Button
24
46
  * my={9}
25
- * width={200}
26
- * variant="solid"
27
- * disabled
28
- * label="Solid Button"
29
- * />
47
+ * variant="text"
48
+ * RightIcon={() => (
49
+ * <Icon name="ri-add-line" color={theme.fonts.primary} size={16} />
50
+ * )}
51
+ * label="Right Icon Text Button"
52
+ * />
30
53
  * </Container>
31
54
  * );
32
55
  * }
@@ -34,63 +57,47 @@ import PropTypes from "prop-types";
34
57
  *
35
58
  */
36
59
 
37
- export const Button = React.forwardRef((props, ref) => {
38
- const {
39
- RightIcon,
40
- LeftIcon,
41
- fontFamily,
42
- color,
43
- fontSize,
44
- loadingText,
45
- isLoading,
46
- Loader,
47
- disabled,
48
- variant,
49
- ...rest
50
- } = props;
51
- let style = rest.style || {};
52
- if (disabled || isLoading) {
53
- style = { ...style, opacity: 0.5 };
54
- }
60
+ export const Button = props => {
61
+ const { variant, label, labelStyle, RightIcon, LeftIcon, disabled, ...rest } =
62
+ props;
63
+ const theme = useContext(ThemeContext);
64
+ const isTextVariant = variant === "text";
55
65
 
56
66
  return (
57
67
  <Touchable
58
- {...(variant === "solid" && { rippleColor: "white" })}
59
- ref={ref}
68
+ rippleColor={isTextVariant ? "black" : "white"}
69
+ disabled={disabled}
70
+ bg={
71
+ isTextVariant
72
+ ? "transparent"
73
+ : theme.colors.background[disabled ? "grey400" : "base"]
74
+ }
75
+ height={45}
76
+ width={isTextVariant ? null : "100%"}
77
+ borderRadius={8}
60
78
  flexDirection="row"
61
- disabled={disabled || isLoading}
79
+ alignItems="center"
80
+ justifyContent="center"
62
81
  {...rest}
63
- variant={variant}
64
- style={style}
65
82
  >
66
- {Loader && isLoading && (
67
- <Container mx={1}>
68
- <Loader />
69
- </Container>
70
- )}
71
83
  {LeftIcon && <LeftIcon />}
72
84
  <Typography
73
85
  textAlign="center"
74
- mx={1}
75
- color={color}
76
- fontFamily={fontFamily || "inter700"}
77
- fontSize={fontSize || "s"}
78
- textStyle={variant}
86
+ mx={2}
87
+ color={theme.colors.font[isTextVariant ? "primary" : "white"]}
88
+ fontSize="m"
89
+ fontFamily={theme.fonts.sf500}
90
+ {...labelStyle}
79
91
  >
80
- {isLoading ? loadingText : rest.label}
92
+ {label}
81
93
  </Typography>
82
94
  {RightIcon && <RightIcon />}
83
95
  </Touchable>
84
96
  );
85
- });
97
+ };
86
98
 
87
99
  Button.defaultProps = {
88
100
  variant: "solid",
89
- p: 12,
90
- alignItems: "center",
91
- justifyContent: "center",
92
- borderRadius: 2,
93
- loadingText: "Loading…",
94
101
  };
95
102
 
96
103
  Button.propTypes = {
@@ -105,33 +112,28 @@ Button.propTypes = {
105
112
  */
106
113
  label: PropTypes.string.isRequired,
107
114
  /**
108
- * Supported Type: 'text' | 'inverse' | 'solid'
115
+ * Supported Type: 'text' | 'solid'
109
116
  * You can change the mode to adjust the styling.
110
117
  * <ul>
111
118
  * <li>text - flat button without background or outline.</li>
112
- * <li>inverse - button with an outline.</li>
113
119
  * <li>solid - button with a background color.</li>
114
120
  * </ul>
115
121
  */
116
- variant: PropTypes.oneOf(["text", "inverse", "solid"]),
122
+ variant: PropTypes.oneOf(["text", "solid"]),
117
123
  /**
118
- * Expects a component.
124
+ * Enable or Disable the button.
119
125
  */
120
- RightIcon: PropTypes.elementType,
126
+ disabled: PropTypes.bool,
121
127
  /**
122
- * Expects a component.
128
+ * Customize label style of the button.
123
129
  */
124
- LeftIcon: PropTypes.elementType,
130
+ labelStyle: PropTypes.object,
125
131
  /**
126
- * Custom text can be specified while loading if default one needs to changed.
132
+ * Render a component on the right side of the Label.
127
133
  */
128
- loadingText: PropTypes.string,
129
- /**
130
- * Whether to show a loading indicator.
131
- */
132
- isLoading: PropTypes.bool,
134
+ RightIcon: PropTypes.elementType,
133
135
  /**
134
- * Expects a component. Is used to override the default loader.
136
+ * Render a component on the left side of the Label.
135
137
  */
136
- Loader: PropTypes.elementType,
138
+ LeftIcon: PropTypes.elementType,
137
139
  };
@@ -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, Typography } from "@bigbinary/neetoui-rn";
27
+ * import { Container, CheckBox } from "@bigbinary/neetoui-rn";
28
28
  *
29
29
  * export default function Main() {
30
- * const [selected, setSelected] = React.useState(false);
31
- *
30
+ * const [checked, setChecked] = useState(true);
32
31
  *
33
32
  * return (
34
33
  * <Container>
35
- * <Container flexDirection="row" my={2}>
36
- * <CheckBox
37
- * selected={selected}
38
- * onSelect={() => setSelected(!selected)}
39
- * checkedComponent={
40
- * <Container width={10} height={10} bg="background.base" />
41
- * }
42
- * label="Agree"
43
- * />
44
- * </Container>
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
- selected = false,
54
- onSelect = () => {},
55
- checkedComponent = null,
56
- checkedItemProp = {},
57
- disabled = false,
58
- label = "Option",
59
- labelComponent = null,
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
- borderColor="background.base"
83
- borderWidth={1}
84
- borderRadius={5}
96
+ height={16}
97
+ width={16}
98
+ borderRadius={3}
85
99
  justifyContent="center"
86
100
  alignItems="center"
87
- width={20}
88
- height={20}
89
- {...checkboxContainerProp}
101
+ {...(!checked && unCheckedProps)}
102
+ {...(checked && checkedProps)}
103
+ {...(disabled && disabledProps)}
104
+ {...checkboxStyle}
90
105
  >
91
- {selected && (
92
- <Container>
93
- {checkedComponent || (
94
- <Typography {...checkedItemProp}>✓</Typography>
95
- )}
96
- </Container>
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
- {labelPosition === labelPositions[1] ? (
100
- <LabelComponent
101
- label={label}
102
- labelComponent={labelComponent}
103
- labelProp={{ ml: 2, ...labelProp }}
104
- />
105
- ) : null}
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 selected.
131
+ * Whether checkbox is checked or not.
113
132
  */
114
- selected: Proptypes.bool.isRequired,
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
- * Props for the label.
147
+ * Customize checkbox style.
137
148
  */
138
- labelProp: Proptypes.object,
149
+ checkboxStyle: Proptypes.object,
139
150
  /**
140
- * Label can passed as a component as well.
151
+ * Customize check icon style.
141
152
  */
142
- labelComponent: Proptypes.element,
153
+ checkIconStyle: Proptypes.object,
143
154
  /**
144
- * Position of label relative to the radio button. It can be either `left` or `right`
155
+ * Customize label style.
145
156
  */
146
- labelPosition: Proptypes.oneOf(labelPositions),
147
- /**
148
- * Extra param to customize checkbox container
149
- */
150
- checkboxContainerProp: Proptypes.object,
157
+ labelStyle: Proptypes.object,
151
158
  };
152
159
 
153
- LabelComponent.propTypes = {
154
- label: Proptypes.string,
155
- labelComponent: Proptypes.element,
156
- labelProp: Proptypes.object,
160
+ CheckBox.defaultProps = {
161
+ checked: false,
162
+ onSelect: () => {},
157
163
  };
@@ -76,7 +76,7 @@ export const Chip = ({
76
76
  {...rest.containerStyle}
77
77
  >
78
78
  {LeftIcon && <LeftIcon />}
79
- <Typography mx={2} fontFamily="inter400" color={labelColor}>
79
+ <Typography mx={2} fontFamily="sf400" color={labelColor}>
80
80
  {label}
81
81
  </Typography>
82
82
  {onClose && (