@sikka/hawa 0.0.21 → 0.0.24

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.
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { HawaTextField } from "../../elements";
3
- import { FormProvider, useForm } from "react-hook-form";
3
+ import { Controller, FormProvider, useForm } from "react-hook-form";
4
4
  import Button from "@mui/material/Button";
5
5
  import Container from "@mui/material/Container";
6
6
 
@@ -8,59 +8,109 @@ export const CreditCardForm = (props) => {
8
8
  const methods = useForm();
9
9
  const {
10
10
  formState: { errors },
11
- handleSubmit
11
+ handleSubmit,
12
+ control
12
13
  } = methods;
13
14
 
14
15
  return (
15
16
  <Container maxWidth="xs">
16
- <FormProvider {...methods}>
17
- <form onSubmit={handleSubmit(props.handle)}>
18
- <HawaTextField
19
- fullWidth
20
- name="password"
21
- placeholder="Enter password"
22
- type="tel"
23
- label="Card Number"
24
- // variant="unscrollable"
25
- // startAdornment={
26
- // <InputAdornment position="start">
27
- // <PasswordIcon />
28
- // </InputAdornment>
29
- // }
30
- rules={{
31
- required: "Password is rquired"
32
- }}
33
- helperText={errors.password?.message}
34
- />
17
+ <form onSubmit={handleSubmit(props.handle)}>
18
+ <HawaTextField
19
+ fullWidth
20
+ name="password"
21
+ placeholder="Enter password"
22
+ type="tel"
23
+ label="Card Number"
24
+ // variant="unscrollable"
25
+ // startAdornment={
26
+ // <InputAdornment position="start">
27
+ // <PasswordIcon />
28
+ // </InputAdornment>
29
+ // }
30
+ rules={{
31
+ required: "Password is rquired"
32
+ }}
33
+ helperText={errors.password?.message}
34
+ />
35
35
 
36
- <HawaTextField
37
- fullWidth
38
- name="password"
39
- placeholder="Enter password"
40
- type="password"
41
- label="Name On Card"
42
- // startAdornment={
43
- // <InputAdornment position="start">
44
- // <PasswordIcon />
45
- // </InputAdornment>
46
- // }
47
- rules={{
48
- required: "Password is rquired"
49
- }}
50
- helperText={errors.password?.message}
51
- />
36
+
37
+ <Controller
38
+ control={control}
39
+ name="cardName"
40
+ render={({ field }) => (
41
+ <HawaTextField
42
+ fullWidth
43
+ name="password"
44
+ placeholder="Enter password"
45
+ type="password"
46
+ label="Name On Card"
47
+ // startAdornment={
48
+ // <InputAdornment position="start">
49
+ // <PasswordIcon />
50
+ // </InputAdornment>
51
+ // }
52
+ rules={{
53
+ required: "Password is rquired"
54
+ }}
55
+ helperText={errors.password?.message}
56
+ />
57
+ )}
58
+ />
59
+ <Controller
60
+ control={control}
61
+ name="cardName"
62
+ render={({ field }) => (
63
+ <HawaTextField
64
+ fullWidth
65
+ name="password"
66
+ placeholder="Enter password"
67
+ type="password"
68
+ label="Expiry Date"
69
+ // startAdornment={
70
+ // <InputAdornment position="start">
71
+ // <PasswordIcon />
72
+ // </InputAdornment>
73
+ // }
74
+ rules={{
75
+ required: "Password is rquired"
76
+ }}
77
+ helperText={errors.password?.message}
78
+ />
79
+ )}
80
+ />
81
+ <Controller
82
+ control={control}
83
+ name="cardName"
84
+ render={({ field }) => (
85
+ <HawaTextField
86
+ fullWidth
87
+ name="password"
88
+ placeholder="Enter password"
89
+ type="password"
90
+ label="CCV"
91
+ // startAdornment={
92
+ // <InputAdornment position="start">
93
+ // <PasswordIcon />
94
+ // </InputAdornment>
95
+ // }
96
+ rules={{
97
+ required: "Password is rquired"
98
+ }}
99
+ helperText={errors.password?.message}
100
+ />
101
+ )}
102
+ />
52
103
 
53
- <Button
54
- type="submit"
55
- fullWidth
56
- variant="last"
57
- onClick={props.handlePayWithCreditCard}
58
- >
59
- {/* {props.texts.signInText} */}
60
- {"Pay with Credit Card"}
61
- </Button>
62
- </form>
63
- </FormProvider>
104
+ <Button
105
+ type="submit"
106
+ fullWidth
107
+ variant="last"
108
+ onClick={props.handlePayWithCreditCard}
109
+ >
110
+ {/* {props.texts.signInText} */}
111
+ {"Pay with Credit Card"}
112
+ </Button>
113
+ </form>
64
114
  </Container>
65
115
  );
66
116
  };
@@ -0,0 +1,39 @@
1
+ import { MenuItem, Menu, Typography, useTheme } from "@mui/material";
2
+
3
+ export const HawaPopMenu = (props) => {
4
+ const theme = useTheme();
5
+ return (
6
+ <Menu
7
+ sx={{ mt: "45px" }}
8
+ id="menu-appbar"
9
+ anchorEl={props.anchor}
10
+ anchorOrigin={{
11
+ vertical: "top",
12
+ horizontal: "right"
13
+ }}
14
+ keepMounted
15
+ transformOrigin={{
16
+ vertical: "top",
17
+ horizontal: "right"
18
+ }}
19
+ open={Boolean(props.anchor)}
20
+ onClose={props.handleClose}
21
+ variant="themed"
22
+ PaperProps={{
23
+ style: {
24
+ boxShadow: "none",
25
+ borderRadius: theme.allBorderRadius,
26
+ border: `1px solid ${theme.primaryActionColor}`
27
+ }
28
+ }}
29
+ >
30
+ {props.menuItems.map((item) => (
31
+ <MenuItem key={item.label} onClick={item.action}>
32
+ {item.icon && <item.icon />}
33
+ <div style={{ width: 10 }} />
34
+ <Typography textAlign="center">{item.label}</Typography>
35
+ </MenuItem>
36
+ ))}
37
+ </Menu>
38
+ );
39
+ };
@@ -1,7 +1,5 @@
1
1
  export * from "./AdaptiveButton";
2
2
  export * from "./ActionButton";
3
- export * from "./HawaListItem";
4
- export * from "./HawaAppBar";
5
3
  export * from "./HawaCheckbox";
6
4
  export * from "./HawaRadio";
7
5
  export * from "./HawaPricingCard";
package/src/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from "./blocks/Account";
2
2
  export * from "./blocks/AuthForms";
3
3
  export * from "./blocks/Payment";
4
+ export * from "./elements";
5
+ export * from "./layout";
@@ -11,11 +11,14 @@ import Avatar from "@mui/material/Avatar";
11
11
  import Button from "@mui/material/Button";
12
12
  import Tooltip from "@mui/material/Tooltip";
13
13
  import MenuItem from "@mui/material/MenuItem";
14
+ import { useTheme } from "@mui/material";
15
+ import { HawaPopMenu } from "../elements/HawaPopMenu";
14
16
 
15
17
  const pages = ["Products", "Pricing", "Blog"];
16
18
  const settings = ["Profile", "Account", "Dashboard", "Logout"];
17
19
 
18
20
  export const HawaAppBar = (props) => {
21
+ const theme = useTheme();
19
22
  const [anchorElNav, setAnchorElNav] = React.useState(null);
20
23
  const [anchorElUser, setAnchorElUser] = React.useState(null);
21
24
 
@@ -33,9 +36,9 @@ export const HawaAppBar = (props) => {
33
36
  const handleCloseUserMenu = () => {
34
37
  setAnchorElUser(null);
35
38
  };
36
-
39
+ console.log("theme is ", theme);
37
40
  return (
38
- <AppBar position="static">
41
+ <AppBar position="static" variant="appbar">
39
42
  <Container maxWidth="xl" variant="appbar">
40
43
  <Toolbar disableGutters>
41
44
  <Typography
@@ -96,7 +99,7 @@ export const HawaAppBar = (props) => {
96
99
  <Button
97
100
  key={page}
98
101
  onClick={handleCloseNavMenu}
99
- sx={{ my: 2, color: "white", display: "block" }}
102
+ sx={{ my: 2, display: "block" }}
100
103
  >
101
104
  {page}
102
105
  </Button>
@@ -109,28 +112,11 @@ export const HawaAppBar = (props) => {
109
112
  <Avatar alt="Remy Sharp" src="/static/images/avatar/2.jpg" />
110
113
  </IconButton>
111
114
  </Tooltip>
112
- <Menu
113
- sx={{ mt: "45px" }}
114
- id="menu-appbar"
115
- anchorEl={anchorElUser}
116
- anchorOrigin={{
117
- vertical: "top",
118
- horizontal: "right"
119
- }}
120
- keepMounted
121
- transformOrigin={{
122
- vertical: "top",
123
- horizontal: "right"
124
- }}
125
- open={Boolean(anchorElUser)}
126
- onClose={handleCloseUserMenu}
127
- >
128
- {settings.map((setting) => (
129
- <MenuItem key={setting} onClick={handleCloseUserMenu}>
130
- <Typography textAlign="center">{setting}</Typography>
131
- </MenuItem>
132
- ))}
133
- </Menu>
115
+ <HawaPopMenu
116
+ anchor={anchorElUser}
117
+ handleClose={(e) => setAnchorElUser(null)}
118
+ menuItems={props.accountMenu}
119
+ />
134
120
  </Box>
135
121
  </Toolbar>
136
122
  </Container>
@@ -5,7 +5,6 @@ import MuiDrawer from "@mui/material/Drawer";
5
5
  import MuiAppBar from "@mui/material/AppBar";
6
6
  import Toolbar from "@mui/material/Toolbar";
7
7
  import List from "@mui/material/List";
8
- // import CssBaseline from "@mui/material/CssBaseline";
9
8
  import Typography from "@mui/material/Typography";
10
9
  import Divider from "@mui/material/Divider";
11
10
  import IconButton from "@mui/material/IconButton";
@@ -13,15 +12,9 @@ import MenuIcon from "@mui/icons-material/Menu";
13
12
  import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
14
13
  import ChevronRightIcon from "@mui/icons-material/ChevronRight";
15
14
  import ListItemButton from "@mui/material/ListItemButton";
16
- import ListItemIcon from "@mui/material/ListItemIcon";
17
15
  import ListItemText from "@mui/material/ListItemText";
18
- import InboxIcon from "@mui/icons-material/MoveToInbox";
19
- import MailIcon from "@mui/icons-material/Mail";
20
- import { HawaListItem } from "../elements";
21
16
  import Menu from "@mui/material/Menu";
22
- import Container from "@mui/material/Container";
23
17
  import Avatar from "@mui/material/Avatar";
24
- import Button from "@mui/material/Button";
25
18
  import Tooltip from "@mui/material/Tooltip";
26
19
  import MenuItem from "@mui/material/MenuItem";
27
20
 
@@ -152,7 +145,7 @@ export function HawaAppLayout(props) {
152
145
  }}
153
146
  >
154
147
  <Typography variant="h6" noWrap component="div">
155
- Page name here
148
+ {props.pageTitle}
156
149
  </Typography>
157
150
 
158
151
  <Box>
@@ -176,10 +169,21 @@ export function HawaAppLayout(props) {
176
169
  }}
177
170
  open={Boolean(anchorElUser)}
178
171
  onClose={handleCloseUserMenu}
172
+ variant="themed"
173
+ PaperProps={{
174
+ style: {
175
+ boxShadow: "none",
176
+ borderRadius: theme.allBorderRadius,
177
+ // borderColor: theme.primaryActionColor,
178
+ // borderWidth: 2,
179
+ border: `1px solid ${theme.primaryActionColor}`
180
+ }
181
+ }}
179
182
  >
180
- {[2, 3, 4].map((setting) => (
181
- <MenuItem key={setting} onClick={handleCloseUserMenu}>
182
- <Typography textAlign="center">{setting}</Typography>
183
+ {props.accountMenu.map((setting) => (
184
+ <MenuItem key={setting.label} onClick={setting.action}>
185
+ {setting.icon && <setting.icon />}
186
+ <Typography textAlign="center">{setting.label}</Typography>
183
187
  </MenuItem>
184
188
  ))}
185
189
  </Menu>
@@ -200,42 +204,39 @@ export function HawaAppLayout(props) {
200
204
  </DrawerHeader>
201
205
  <Divider />
202
206
  <List>
203
- {props.pages.map((t) => {
207
+ {props.pages.map((p, jk) => {
204
208
  return (
205
- <HawaListItem
206
- open={open}
207
- text={t.text}
208
- selected={props.pageName.toLowerCase() === t.text}
209
- // icon={<ChevronLeftIcon />}
210
- icon={t.icon}
211
- />
209
+ <Tooltip
210
+ title={p.text}
211
+ key={jk}
212
+ placement={"right"}
213
+ arrow={true}
214
+ PopperProps={{ style: { opacity: open ? 0 : 1 } }}
215
+ >
216
+ <ListItemButton
217
+ variant={
218
+ props.pageName?.toLowerCase() === p.slug?.toLowerCase() &&
219
+ "clicked"
220
+ }
221
+ onClick={p.action}
222
+ key={p.text}
223
+ sx={{
224
+ minHeight: 48,
225
+ justifyContent: open ? "initial" : "center",
226
+ px: 2.5
227
+ }}
228
+ >
229
+ <p.icon />
230
+ <div style={{ width: 20 }} />
231
+ <ListItemText
232
+ primary={p.text}
233
+ sx={{ opacity: open ? 1 : 0 }}
234
+ />
235
+ </ListItemButton>
236
+ </Tooltip>
212
237
  );
213
238
  })}
214
239
  </List>
215
- <Divider />
216
- <List>
217
- {["All mail", "Trash", "Spam"].map((text, index) => (
218
- <ListItemButton
219
- key={text}
220
- sx={{
221
- minHeight: 48,
222
- justifyContent: open ? "initial" : "center",
223
- px: 2.5
224
- }}
225
- >
226
- <ListItemIcon
227
- sx={{
228
- minWidth: 0,
229
- mr: open ? 3 : "auto",
230
- justifyContent: "center"
231
- }}
232
- >
233
- {index % 2 === 0 ? <InboxIcon /> : <MailIcon />}
234
- </ListItemIcon>
235
- <ListItemText primary={text} sx={{ opacity: open ? 1 : 0 }} />
236
- </ListItemButton>
237
- ))}
238
- </List>
239
240
  </Drawer>
240
241
  <Box sx={{ flexGrow: 1, p: 3 }}>
241
242
  <DrawerHeader />
@@ -1,3 +1,4 @@
1
1
  export * from "./Box";
2
2
  export * from "./HawaAppLayout";
3
3
  export * from "./HawaDialog";
4
+ export * from "./HawaAppBar";
@@ -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.708d7ac1.iframe.bundle.js"></script><script src="vendors~main.4ff76500.iframe.bundle.js"></script><script src="main.e1b79522.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.708d7ac1.iframe.bundle.js"></script><script src="vendors~main.62e56b46.iframe.bundle.js"></script><script src="main.3715c835.iframe.bundle.js"></script></body></html>