@bigbinary/neetoui-rn 0.0.21 → 0.0.22

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.
@@ -9,7 +9,8 @@ import {
9
9
  } from "styled-system";
10
10
  import styled from "styled-components/native";
11
11
  import propTypes from "@styled-system/prop-types";
12
- import { Typography } from "@components";
12
+ import { Typography, Container } from "@components";
13
+ import PropTypes from "prop-types";
13
14
 
14
15
  export const TouchableOpacity = styled.TouchableOpacity`
15
16
  ${buttonStyle}
@@ -26,32 +27,43 @@ export const Button = ({
26
27
  fontFamily,
27
28
  color,
28
29
  fontSize,
30
+ loadingText,
31
+ isLoading,
32
+ Loader,
33
+ disabled,
34
+ variant,
29
35
  ...rest
30
36
  }) => {
31
- const { disabled } = rest;
32
37
  let style = rest.style || {};
33
- if (disabled) {
38
+ if (disabled || isLoading) {
34
39
  style = { ...style, opacity: 0.5 };
35
40
  }
41
+
36
42
  return (
37
43
  <TouchableOpacity
38
44
  flexDirection="row"
39
- disabled={disabled}
45
+ disabled={disabled || isLoading}
40
46
  {...rest}
47
+ variant={variant}
41
48
  style={style}
42
49
  >
43
- {RightIcon && <RightIcon />}
50
+ {Loader && (
51
+ <Container mx={1}>
52
+ <Loader />
53
+ </Container>
54
+ )}
55
+ {LeftIcon && <LeftIcon />}
44
56
  <Typography
45
57
  textAlign="center"
46
58
  mx={1}
47
59
  color={color}
48
60
  fontFamily={fontFamily || "inter700"}
49
61
  fontSize={fontSize || "s"}
50
- textStyle={rest.variant}
62
+ textStyle={variant}
51
63
  >
52
- {rest.label}
64
+ {isLoading ? loadingText : rest.label}
53
65
  </Typography>
54
- {LeftIcon && <LeftIcon />}
66
+ {RightIcon && <RightIcon />}
55
67
  </TouchableOpacity>
56
68
  );
57
69
  };
@@ -62,6 +74,7 @@ Button.defaultProps = {
62
74
  alignItems: "center",
63
75
  justifyContent: "center",
64
76
  borderRadius: 2,
77
+ loadingText: "Loading…",
65
78
  };
66
79
 
67
80
  Button.propTypes = {
@@ -71,4 +84,10 @@ Button.propTypes = {
71
84
  ...propTypes.border,
72
85
  ...propTypes.layout,
73
86
  ...propTypes.color,
87
+ label: PropTypes.string.isRequired,
88
+ RightIcon: PropTypes.elementType,
89
+ LeftIcon: PropTypes.elementType,
90
+ loadingText: PropTypes.string,
91
+ isLoading: PropTypes.bool,
92
+ Loader: PropTypes.elementType,
74
93
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neetoui-rn",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "main": "lib/index.js",
5
5
  "author": "BigBinary",
6
6
  "license": "MIT",