@sikka/hawa 0.0.6 → 0.0.9

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 (57) hide show
  1. package/es/index.es.js +1 -1
  2. package/lib/index.js +1 -1
  3. package/package.json +2 -1
  4. package/src/blocks/Account/UserProfile.js +57 -7
  5. package/src/blocks/AuthForms/NewPasswordForm.js +59 -42
  6. package/src/blocks/AuthForms/ResetPasswordForm.js +46 -33
  7. package/src/blocks/AuthForms/SignInForm.js +60 -32
  8. package/src/blocks/AuthForms/SignUpForm.js +74 -45
  9. package/src/blocks/Payment/ChargeWalletForm.js +38 -17
  10. package/src/blocks/Payment/CreditCardForm.js +50 -21
  11. package/src/blocks/Payment/PayWithWallet.js +4 -25
  12. package/src/blocks/Payment/SelectPayment.js +18 -39
  13. package/src/layout/Box.js +9 -9
  14. package/src/stories/BlocksStories/AuthForm.stories.js +9 -9
  15. package/src/stories/BlocksStories/PaymentForm.stories.js +10 -6
  16. package/src/stories/BlocksStories/UserForm.stories.js +41 -0
  17. package/src/stories/Introduction.stories.mdx +229 -0
  18. package/src/stories/LayoutStories/Box.stories.js +4 -4
  19. package/src/stories/UIStories/ActionButton.stories.js +15 -22
  20. package/src/stories/UIStories/AdaptiveButton.stories.js +43 -42
  21. package/src/stories/UIStories/Alert.stories.js +4 -17
  22. package/src/stories/UIStories/LogoButtons.stories.js +90 -0
  23. package/src/stories/UIStories/RadioSelector.stories.js +20 -35
  24. package/src/stories/UIStories/SettingsRow.stories.js +64 -0
  25. package/src/themes/HawaProvider.js +64 -20
  26. package/src/ui/ActionButton.js +12 -11
  27. package/src/ui/AdaptiveButton.js +43 -159
  28. package/src/ui/HawaAlert.js +6 -6
  29. package/src/ui/HawaButton.js +6 -6
  30. package/src/ui/HawaInputLabel.js +4 -4
  31. package/src/ui/HawaLogoButton.js +102 -12
  32. package/src/ui/HawaRadio.js +50 -28
  33. package/src/ui/HawaSettingsRow.js +71 -0
  34. package/src/ui/HawaTextField.js +29 -35
  35. package/src/ui/HawaTypography.js +5 -6
  36. package/src/ui/index.js +2 -15
  37. package/storybook-static/iframe.html +1 -1
  38. package/storybook-static/main.5731dbe3.iframe.bundle.js +1 -0
  39. package/storybook-static/vendors~main.aa1d952a.iframe.bundle.js +76 -0
  40. package/storybook-static/{vendors~main.30a2c5d7.iframe.bundle.js.LICENSE.txt → vendors~main.aa1d952a.iframe.bundle.js.LICENSE.txt} +0 -15
  41. package/storybook-static/vendors~main.aa1d952a.iframe.bundle.js.map +1 -0
  42. package/src/stories/BlocksStories/UserAccount.stories.js +0 -46
  43. package/src/stories/GlobalVariables.stories.js +0 -44
  44. package/src/stories/Introduction.stories.js +0 -233
  45. package/src/ui/ApplePayButton.js +0 -93
  46. package/src/ui/GithubButton.js +0 -90
  47. package/src/ui/GoogleButton.js +0 -82
  48. package/src/ui/GooglePayButton.js +0 -93
  49. package/src/ui/MadaButton.js +0 -93
  50. package/src/ui/PayPalButton.js +0 -93
  51. package/src/ui/STCPayButton.js +0 -93
  52. package/src/ui/TwitterButton.js +0 -83
  53. package/src/ui/VisaMasterButton.js +0 -93
  54. package/src/ui/WalletButton.js +0 -24
  55. package/storybook-static/main.e55ce615.iframe.bundle.js +0 -1
  56. package/storybook-static/vendors~main.30a2c5d7.iframe.bundle.js +0 -76
  57. package/storybook-static/vendors~main.30a2c5d7.iframe.bundle.js.map +0 -1
@@ -2,21 +2,20 @@ import React, { useContext } from "react";
2
2
  import { ThemeProvider } from "../themes/HawaProvider";
3
3
  import { styled, darken } from "@mui/material/styles";
4
4
  import Button from "@mui/material/Button";
5
+ import GitHubIcon from "@mui/icons-material/GitHub";
6
+ import TwitterIcon from "@mui/icons-material/Twitter";
7
+ import WalletIcon from "@mui/icons-material/AccountBalanceWallet";
5
8
 
6
9
  export const HawaLogoButton = (props) => {
7
- const theme = useContext(ThemeProvider);
10
+ const { hawaTheme, themeName } = useContext(ThemeProvider);
8
11
  let buttonStyle = {};
9
- let currentTheme = Object.keys(theme.logoButton).find(
10
- (themeName) => themeName.toLowerCase() === props.themeType?.toLowerCase()
12
+ let currentTheme = Object.keys(hawaTheme.logoButton).find(
13
+ (tName) => tName.toLowerCase() === themeName?.toLowerCase()
11
14
  );
12
15
  if (currentTheme) {
13
16
  buttonStyle = {
14
- ...theme.logoButton[currentTheme],
15
- // marginTop: theme.actionButton[currentTheme].margin,
16
- border: props.outlined ? "2px solid black" : "none",
17
- // borderRadius: theme.actionButton[currentTheme].borderRadius,
17
+ ...hawaTheme.logoButton[currentTheme],
18
18
  backgroundColor: "white",
19
- // height: 50,
20
19
  "&:hover": {
21
20
  backgroundColor: darken("#ffffff", 0.1)
22
21
  }
@@ -29,10 +28,12 @@ export const HawaLogoButton = (props) => {
29
28
  flexDirection: "row",
30
29
  alignItems: "center",
31
30
  justifyContent: "center",
32
- marginTop: theme.logoButton[currentTheme]?.margin,
33
- border: props.outlined ? "2px solid black" : "none",
34
- // borderRadius: 0,
31
+ marginTop: 10,
35
32
  height: 50,
33
+ padding: 30,
34
+ paddingTop: 0,
35
+ paddingBottom: 0,
36
+ border: "1px solid #ced4da",
36
37
  backgroundColor: "white",
37
38
  "&:hover": {
38
39
  backgroundColor: darken("#ffffff", 0.1)
@@ -44,5 +45,94 @@ export const HawaLogoButton = (props) => {
44
45
  ...buttonStyle
45
46
  };
46
47
  });
47
- return <StyledButton {...props}>{props.children}</StyledButton>;
48
+ let logoElement = "";
49
+ switch (props.logo?.toLowerCase()) {
50
+ case "google":
51
+ logoElement = (
52
+ <img
53
+ src={
54
+ "https://upload.wikimedia.org/wikipedia/commons/5/53/Google_%22G%22_Logo.svg"
55
+ }
56
+ />
57
+ );
58
+ break;
59
+ case "github":
60
+ logoElement = <GitHubIcon />;
61
+ break;
62
+ case "twitter":
63
+ logoElement = <TwitterIcon />;
64
+ break;
65
+ case "mada":
66
+ logoElement = (
67
+ <img
68
+ src="https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/mada.png"
69
+ height={20}
70
+ />
71
+ );
72
+ break;
73
+ case "stcpay":
74
+ logoElement = (
75
+ <img
76
+ src="https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/stc-pay.png"
77
+ height={20}
78
+ />
79
+ );
80
+ break;
81
+ case "visa/master":
82
+ logoElement = (
83
+ <img
84
+ src="https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/visa-master.png"
85
+ height={30}
86
+ />
87
+ );
88
+ break;
89
+ case "paypal":
90
+ logoElement = (
91
+ <img
92
+ src="https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/paypal.png"
93
+ height={25}
94
+ />
95
+ );
96
+ break;
97
+ case "googlepay":
98
+ logoElement = (
99
+ <img
100
+ src="https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/google-pay.png"
101
+ height={20}
102
+ />
103
+ );
104
+ break;
105
+ case "applepay":
106
+ logoElement = (
107
+ <img
108
+ src="https://sikka-images.s3.ap-southeast-1.amazonaws.com/payments/apple-pay.png"
109
+ height={40}
110
+ />
111
+ );
112
+ break;
113
+ case "wallet":
114
+ logoElement = <WalletIcon />;
115
+ break;
116
+
117
+ default:
118
+ break;
119
+ }
120
+ return (
121
+ <StyledButton {...props}>
122
+ {logoElement}
123
+ <div style={{ width: 10 }} />
124
+ <p
125
+ style={{
126
+ color: "black",
127
+ fontSize: 14,
128
+ textAlign: "center",
129
+ letterSpacing: 0.4,
130
+ fontFamily: "Roboto",
131
+ fontWeight: 500
132
+ }}
133
+ >
134
+ {props.buttonText}
135
+ </p>
136
+ </StyledButton>
137
+ );
48
138
  };
@@ -1,51 +1,73 @@
1
+ import { Typography } from "@mui/material";
1
2
  import React, { useState, useContext } from "react";
3
+ import { Box } from "../layout";
2
4
  import { ThemeProvider } from "../themes/HawaProvider";
3
5
 
4
6
  export const HawaRadio = (props) => {
5
7
  const [value, setValue] = useState(props.defaultValue);
6
- const theme = useContext(ThemeProvider);
8
+
9
+ const { hawaTheme, themeName } = useContext(ThemeProvider);
10
+ const currentTheme = Object.keys(hawaTheme.radioSelector).find(
11
+ (tName) => tName.toLowerCase() === themeName?.toLowerCase()
12
+ );
13
+ let radioSelectorStyle = {};
14
+
15
+ if (currentTheme) {
16
+ radioSelectorStyle = {
17
+ ...hawaTheme.radioSelector[currentTheme],
18
+ "-moz-user-select": "-moz-none",
19
+ "-khtml-user-select": "none",
20
+ "-webkit-user-select": "none",
21
+ "-ms-user-select": "none",
22
+ "user-select": "none"
23
+ };
24
+ } else {
25
+ radioSelectorStyle = {
26
+ display: "flex",
27
+ flexDirection: "row",
28
+ justifyContent: "space-between",
29
+ alignItems: "center",
30
+ backgroundColor: "#F5F5F5",
31
+ margin: 0,
32
+
33
+ backgroundColor: "lightGrey",
34
+ color: "black",
35
+ padding: 10
36
+ };
37
+ }
7
38
 
8
39
  return (
9
- <div
10
- style={{
11
- backgroundColor: "white",
12
- display: "flex",
13
- flexDirection: "row",
14
- margin: theme.margins,
15
- padding: theme.paddings,
16
- marginBottom: 10
17
- }}
18
- >
40
+ <Box horizontal maxWidth={"fit-content"}>
19
41
  {props.options.map((singleOption) => {
20
42
  return (
21
43
  <div
22
44
  key={singleOption.label}
23
- className="radio_option"
24
45
  onClick={() => {
25
46
  setValue(singleOption.label);
26
47
  if (props.handleChange) {
27
48
  props.handleChange();
28
49
  }
29
50
  }}
30
- style={
31
- value.toLowerCase() === singleOption.label.toLowerCase()
32
- ? {
33
- borderRadius: theme.borderRadius,
34
- padding: theme.paddings,
35
- backgroundColor:
36
- theme.primaryColor || props.bgSelectedColor || "blue",
37
- color: props.textSelectedColor || "lightgray"
38
- }
39
- : {
40
- borderRadius: theme.borderRadius,
41
- padding: theme.paddings
42
- }
43
- }
51
+ style={{
52
+ ...radioSelectorStyle,
53
+ backgroundColor:
54
+ value.toLowerCase() === singleOption.label.toLowerCase()
55
+ ? currentTheme
56
+ ? hawaTheme.actionButton[currentTheme]?.backgroundColor
57
+ : "black"
58
+ : hawaTheme?.layout[currentTheme]?.backgroundColor,
59
+ color:
60
+ value.toLowerCase() === singleOption.label.toLowerCase()
61
+ ? hawaTheme.actionButton[currentTheme]?.color
62
+ : currentTheme
63
+ ? hawaTheme?.layout[currentTheme]?.color
64
+ : "black"
65
+ }}
44
66
  >
45
- {singleOption.text}
67
+ <Typography>{singleOption.text}</Typography>
46
68
  </div>
47
69
  );
48
70
  })}
49
- </div>
71
+ </Box>
50
72
  );
51
73
  };
@@ -0,0 +1,71 @@
1
+ import React, { useContext } from "react";
2
+
3
+ import PropTypes from "prop-types";
4
+ import { ThemeProvider } from "../themes/HawaProvider";
5
+ import { Box } from "../layout";
6
+ import Checkbox from "@mui/material/Checkbox";
7
+ import TextField from "@mui/material/TextField";
8
+ import { HawaTypography } from "./HawaTypography";
9
+ export const HawaSettingsRow = (props) => {
10
+ const { hawaTheme, themeName } = useContext(ThemeProvider);
11
+ const currentTheme = Object.keys(hawaTheme.settingsRow).find(
12
+ (tName) => tName.toLowerCase() === themeName?.toLowerCase()
13
+ );
14
+ let settingsRowStyle = {};
15
+
16
+ if (currentTheme) {
17
+ settingsRowStyle = {
18
+ ...hawaTheme.settingsRow[currentTheme],
19
+ margin: props.last ? 0 : hawaTheme.settingsRow[currentTheme].margin,
20
+ marginTop: props.last ? hawaTheme.settingsRow[currentTheme].margin * 2 : 0
21
+ };
22
+ } else {
23
+ settingsRowStyle = {
24
+ display: "flex",
25
+ flexDirection: "row",
26
+ justifyContent: "space-between",
27
+ alignItems: "center",
28
+ backgroundColor: "#F5F5F5",
29
+ margin: 0,
30
+
31
+ backgroundColor: "lightGrey",
32
+ color: "black",
33
+ padding: 10
34
+ };
35
+ }
36
+
37
+ return (
38
+ <Box noColor>
39
+ {props.settingsType === "checkbox" && (
40
+ <div style={{ ...settingsRowStyle }}>
41
+ <HawaTypography>Checkbox Label</HawaTypography> <Checkbox />
42
+ </div>
43
+ )}
44
+ {props.settingsType === "text" && (
45
+ <div style={{ ...settingsRowStyle }}>
46
+ Text Label{" "}
47
+ <TextField
48
+ InputProps={{
49
+ style: {
50
+ ...hawaTheme.inputFields[currentTheme],
51
+ // borderRadius: 0,
52
+ // padding: 0,
53
+ // backgroundColor: "white",
54
+ height: 40
55
+ }
56
+ }}
57
+ style={{
58
+ padding: 0
59
+ }}
60
+ placeholder="test"
61
+ />
62
+ </div>
63
+ )}
64
+ </Box>
65
+ );
66
+ };
67
+
68
+ HawaSettingsRow.propTypes = {
69
+ type: PropTypes.oneOf(["text", "number", "password"]),
70
+ helperText: PropTypes.string
71
+ };
@@ -1,7 +1,7 @@
1
1
  import React, { useContext } from "react";
2
2
  import InputBase from "@mui/material/InputBase";
3
3
  import Typography from "@mui/material/Typography";
4
- import { styled, alpha } from "@mui/material/styles";
4
+ import { styled } from "@mui/material/styles";
5
5
  import PropTypes from "prop-types";
6
6
  import { ThemeProvider } from "../themes/HawaProvider";
7
7
  import { HawaInputLabel } from "./HawaInputLabel";
@@ -10,25 +10,21 @@ import { Controller, useFormContext } from "react-hook-form";
10
10
  export const HawaTextField = (props) => {
11
11
  const { control, register } = useFormContext();
12
12
 
13
- const theme = useContext(ThemeProvider);
14
- const currentTheme = Object.keys(theme.actionButton).find(
15
- (themeName) => themeName.toLowerCase() === props.themeType?.toLowerCase()
13
+ const { hawaTheme, themeName } = useContext(ThemeProvider);
14
+ const currentTheme = Object.keys(hawaTheme.inputFields).find(
15
+ (tName) => tName.toLowerCase() === themeName?.toLowerCase()
16
16
  );
17
17
  let textFieldStyle = {};
18
18
 
19
19
  if (currentTheme) {
20
20
  textFieldStyle = {
21
- ...theme.inputFields[currentTheme],
22
- margin: props.last ? 0 : theme.inputFields[currentTheme].margin,
23
- marginTop: props.last ? theme.inputFields[currentTheme].margin * 2 : 0
21
+ ...hawaTheme.inputFields[currentTheme],
22
+ margin: props.last ? 0 : hawaTheme.inputFields[currentTheme].margin,
23
+ marginTop: props.last ? hawaTheme.inputFields[currentTheme].margin * 2 : 0
24
24
  };
25
25
  } else {
26
26
  textFieldStyle = {
27
- backgroundColor: "white",
28
- display: "flex",
29
- flexDirection: "column",
30
- alignItems: "flex-start",
31
- justifyContent: "flex-start"
27
+ backgroundColor: "white"
32
28
  };
33
29
  }
34
30
 
@@ -38,27 +34,26 @@ export const HawaTextField = (props) => {
38
34
  // marginTop: theme.spacing(3)
39
35
  // },
40
36
  "& .MuiInputBase-input": {
41
- backgroundColor: theme.palette.mode === "light" ? "#fcfcfb" : "#2b2b2b",
37
+ // backgroundColor: theme.palette.mode === "light" ? "#fcfcfb" : "#2b2b2b",
42
38
  transition: theme.transitions.create([
43
39
  "border-color",
44
40
  "background-color",
45
41
  "box-shadow"
46
- ]),
42
+ ])
47
43
 
48
- "&:focus": {
49
- // boxShadow: `${alpha(theme.palette.primary.main, 0.25)} 0 0 0 0.2rem`,
50
- // borderColor: theme.palette.primary.main
51
- // borderColor: theme.actionButton[currentTheme]?.backgroundColor
52
- },
53
- borderRadius: 4,
54
- // position: "relative",
55
- border: "1px solid #ced4da",
56
- fontSize: 16,
57
- // width: "auto",
58
- padding: "10px 12px",
59
- marginBottom: props.helperText ? 5 : 0,
60
- ...textFieldStyle
61
- }
44
+ // backgroundColor: "red"
45
+ },
46
+
47
+ // position: "relative",
48
+ border: "1px solid #ced4da",
49
+ fontSize: 16,
50
+ // width: "auto",
51
+ padding: "10px 12px",
52
+ marginBottom: props.helperText ? 5 : 0,
53
+ paddingLeft: 10,
54
+ paddingRight: 10,
55
+ ...textFieldStyle
56
+ // backgroundColor: "green"
62
57
  };
63
58
  });
64
59
 
@@ -66,12 +61,7 @@ export const HawaTextField = (props) => {
66
61
  <Controller
67
62
  render={({ field }) => (
68
63
  <>
69
- {props.inputLabel && (
70
- <HawaInputLabel
71
- themeType={props.themeType}
72
- label={props.inputLabel}
73
- />
74
- )}
64
+ {props.inputLabel && <HawaInputLabel label={props.inputLabel} />}
75
65
 
76
66
  <StyledTextField
77
67
  fullWidth={true}
@@ -88,13 +78,17 @@ export const HawaTextField = (props) => {
88
78
  // }
89
79
  // : {}
90
80
  // }
81
+
91
82
  defaultValue={props.defaultValue && ""}
92
83
  value={props.value && ""}
93
84
  {...props}
94
85
  // {...field}
95
86
  {...register(props.name)}
96
87
  />
97
- <Typography variant="caption" style={{ margin: 5, color: "red" }}>
88
+ <Typography
89
+ variant="caption"
90
+ style={{ margin: 5, marginBottom: 0, color: "red" }}
91
+ >
98
92
  {props.helperText}
99
93
  </Typography>
100
94
  </>
@@ -1,18 +1,17 @@
1
1
  import React, { useContext } from "react";
2
- import { styled, alpha } from "@mui/material/styles";
3
- import PropTypes from "prop-types";
2
+ import { styled } from "@mui/material/styles";
4
3
  import { ThemeProvider } from "../themes/HawaProvider";
5
4
  import Typography from "@mui/material/Typography";
6
5
 
7
6
  export const HawaTypography = (props) => {
8
- const theme = useContext(ThemeProvider);
9
- const currentTheme = Object.keys(theme.actionButton).find(
10
- (themeName) => themeName.toLowerCase() === props.themeType?.toLowerCase()
7
+ const { hawaTheme, themeName } = useContext(ThemeProvider);
8
+ const currentTheme = Object.keys(hawaTheme.typography).find(
9
+ (tName) => tName.toLowerCase() === themeName?.toLowerCase()
11
10
  );
12
11
  let typographyStyle = {};
13
12
 
14
13
  if (currentTheme) {
15
- typographyStyle = { ...theme.typography[currentTheme] };
14
+ typographyStyle = { ...hawaTheme.typography[currentTheme] };
16
15
  } else {
17
16
  typographyStyle = {
18
17
  color: "black"
package/src/ui/index.js CHANGED
@@ -2,24 +2,11 @@ export * from "./AdaptiveButton";
2
2
  export * from "./ActionButton";
3
3
  export * from "./HawaCheckbox";
4
4
  export * from "./HawaRadio";
5
- // export * from "./RadioSelector";
6
- // export * from "./Row";
7
- // export * from "./SelectedField";
8
- // export * from "./TabPanel";
5
+
6
+ export * from "./HawaSettingsRow";
9
7
  export * from "./HawaLogoButton";
10
8
  export * from "./HawaButton";
11
9
  export * from "./HawaTextField";
12
10
  export * from "./HawaInputLabel";
13
11
  export * from "./HawaTypography";
14
12
  export * from "./HawaAlert";
15
-
16
- export * from "./GoogleButton";
17
- export * from "./GithubButton";
18
- export * from "./TwitterButton";
19
- export * from "./VisaMasterButton";
20
- export * from "./MadaButton";
21
- export * from "./STCPayButton";
22
- export * from "./PayPalButton";
23
- export * from "./ApplePayButton";
24
- export * from "./GooglePayButton";
25
- export * from "./WalletButton";
@@ -345,4 +345,4 @@
345
345
 
346
346
 
347
347
 
348
- window['STORIES'] = [{"titlePrefix":"","directory":"./src","files":"**/*.stories.mdx","importPathMatcher":"^\\.[\\\\/](?:src(?:[\\\\/](?!\\.)(?:(?:(?!(?:^|[\\\\/])\\.).)*?)[\\\\/]|[\\\\/]|$)(?!\\.)(?=.)[^\\\\/]*?\\.stories\\.mdx)$"},{"titlePrefix":"","directory":"./src","files":"**/*.stories.@(js|jsx|ts|tsx)","importPathMatcher":"^\\.[\\\\/](?:src(?:[\\\\/](?!\\.)(?:(?:(?!(?:^|[\\\\/])\\.).)*?)[\\\\/]|[\\\\/]|$)(?!\\.)(?=.)[^\\\\/]*?\\.stories\\.(js|jsx|ts|tsx))$"}];</script><script src="runtime~main.cfefe972.iframe.bundle.js"></script><script src="vendors~main.30a2c5d7.iframe.bundle.js"></script><script src="main.e55ce615.iframe.bundle.js"></script></body></html>
348
+ window['STORIES'] = [{"titlePrefix":"","directory":"./src","files":"**/*.stories.mdx","importPathMatcher":"^\\.[\\\\/](?:src(?:[\\\\/](?!\\.)(?:(?:(?!(?:^|[\\\\/])\\.).)*?)[\\\\/]|[\\\\/]|$)(?!\\.)(?=.)[^\\\\/]*?\\.stories\\.mdx)$"},{"titlePrefix":"","directory":"./src","files":"**/*.stories.@(js|jsx|ts|tsx)","importPathMatcher":"^\\.[\\\\/](?:src(?:[\\\\/](?!\\.)(?:(?:(?!(?:^|[\\\\/])\\.).)*?)[\\\\/]|[\\\\/]|$)(?!\\.)(?=.)[^\\\\/]*?\\.stories\\.(js|jsx|ts|tsx))$"}];</script><script src="runtime~main.cfefe972.iframe.bundle.js"></script><script src="vendors~main.aa1d952a.iframe.bundle.js"></script><script src="main.5731dbe3.iframe.bundle.js"></script></body></html>