@sikka/hawa 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "SaaS Oriented UI Kit",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.es.js",
@@ -1,7 +1,14 @@
1
1
  import React, { FC } from "react"
2
2
  import { Controller, useForm } from "react-hook-form"
3
- import { HawaButton, HawaTextField } from "../../elements"
4
- import { HawaContainer } from "../../layout"
3
+ import { HawaTextField } from "../../elements"
4
+ import {
5
+ Card,
6
+ CardContent,
7
+ CardDescription,
8
+ CardHeader,
9
+ CardTitle,
10
+ } from "../../elements/Card"
11
+ import { Button } from "../../elements/Button"
5
12
 
6
13
  type ResetPasswordType = {
7
14
  handleResetPassword: () => void
@@ -28,52 +35,55 @@ export const ResetPasswordForm: FC<ResetPasswordType> = (props) => {
28
35
  control,
29
36
  } = methods
30
37
  return (
31
- <HawaContainer>
32
- {!props.sent ? (
33
- <form onSubmit={handleSubmit(props.handleResetPassword)}>
34
- <Controller
35
- control={control}
36
- name="email"
37
- render={({ field }) => (
38
- <HawaTextField
39
- width="full"
40
- type="text"
41
- label={props.texts.emailLabel}
42
- helpertext={errors.email?.message}
43
- placeholder={props.texts.emailPlaceholder}
44
- {...field}
45
- value={field.value ?? ""}
46
- />
47
- )}
48
- rules={{
49
- required: props.texts.emailRequiredText,
50
- pattern: {
51
- value:
52
- /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
53
- message: props.texts.emailInvalidText,
54
- },
55
- }}
56
- />
57
- <div className=" pb-2 text-left text-sm dark:text-gray-300">
58
- {props.texts.dontHaveAccount ?? "Don't have an account? "}
59
- <span
60
- onClick={props.handleRouteToSignUp}
61
- className="cursor-pointer text-blue-600 dark:text-blue-400"
62
- >
63
- {props.texts.signUpText ?? "Sign Up"}
64
- </span>
65
- </div>
66
- <HawaButton
67
- color="primary"
68
- width="full"
69
- // type="submit"
70
- >
71
- {props.texts.resetPassword}
72
- </HawaButton>
73
- </form>
74
- ) : (
75
- <div className="text-center">{props.texts.emailSentText}</div>
76
- )}
77
- </HawaContainer>
38
+ <Card>
39
+ <CardHeader>
40
+ <CardTitle>Reset Password</CardTitle>
41
+ <CardDescription>
42
+ Enter your email to reset your account password
43
+ </CardDescription>
44
+ </CardHeader>
45
+ <CardContent>
46
+ {!props.sent ? (
47
+ <form onSubmit={handleSubmit(props.handleResetPassword)}>
48
+ <Controller
49
+ control={control}
50
+ name="email"
51
+ render={({ field }) => (
52
+ <HawaTextField
53
+ width="full"
54
+ type="text"
55
+ label={props.texts.emailLabel}
56
+ helpertext={errors.email?.message}
57
+ placeholder={props.texts.emailPlaceholder}
58
+ {...field}
59
+ value={field.value ?? ""}
60
+ />
61
+ )}
62
+ rules={{
63
+ required: props.texts.emailRequiredText,
64
+ pattern: {
65
+ value:
66
+ /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
67
+ message: props.texts.emailInvalidText,
68
+ },
69
+ }}
70
+ />
71
+ <div className=" pb-2 text-left text-sm dark:text-gray-300">
72
+ {props.texts.dontHaveAccount ?? "Don't have an account? "}
73
+ <span
74
+ onClick={props.handleRouteToSignUp}
75
+ className="cursor-pointer text-blue-600 dark:text-blue-400"
76
+ >
77
+ {props.texts.signUpText ?? "Sign Up"}
78
+ </span>
79
+ </div>
80
+
81
+ <Button className="w-full">{props.texts.resetPassword}</Button>
82
+ </form>
83
+ ) : (
84
+ <div className="text-center">{props.texts.emailSentText}</div>
85
+ )}
86
+ </CardContent>
87
+ </Card>
78
88
  )
79
89
  }
@@ -10,6 +10,9 @@ import { Controller, useForm } from "react-hook-form"
10
10
  import { HawaContainer } from "../../layout"
11
11
  import { Button } from "../../elements/Button"
12
12
  import { FaGithub, FaGoogle } from "react-icons/fa"
13
+ import { Card, CardContent, CardFooter, CardHeader } from "../../elements/Card"
14
+ import { Icons } from "../../elements/Icons"
15
+ import clsx from "clsx"
13
16
 
14
17
  export const SignInForm: FC<SignInFormTypes> = (props) => {
15
18
  const {
@@ -19,174 +22,161 @@ export const SignInForm: FC<SignInFormTypes> = (props) => {
19
22
  } = useForm()
20
23
 
21
24
  return (
22
- <HawaContainer direction={props.direction}>
23
- <form onSubmit={handleSubmit((e) => props.handleSignIn(e))}>
24
- {props.showError && (
25
- <HawaAlert
26
- title={props.errorTitle}
27
- text={props.errorText}
28
- severity="error"
29
- />
30
- )}
31
- {props.signInType === "email" ? (
32
- <Controller
33
- control={control}
34
- name="email"
35
- render={({ field }) => (
36
- <HawaTextField
37
- width="full"
38
- type="text"
39
- autoComplete="email"
40
- label={props.texts.emailLabel}
41
- helpertext={errors.email?.message}
42
- placeholder={props.texts.emailPlaceholder}
43
- value={field.value ?? ""}
44
- onChange={field.onChange}
45
- />
46
- )}
47
- rules={{
48
- required: props.texts.emailRequiredText,
49
- pattern: {
50
- value:
51
- /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
52
- message: props.texts.emailInvalidText,
53
- },
54
- }}
55
- />
56
- ) : props.signInType === "username" ? (
57
- <Controller
58
- control={control}
59
- name="username"
60
- render={({ field }) => {
61
- return (
62
- <HawaTextField
63
- width="full"
64
- type="text"
65
- autoComplete="username"
66
- label={props.texts.usernameLabel}
67
- helpertext={errors.username?.message}
68
- placeholder={props.texts.usernamePlaceholder}
69
- onChange={field.onChange}
70
- value={field.value ?? ""}
71
- />
72
- )
73
- }}
74
- rules={{
75
- required: props.texts.usernameRequired,
76
- }}
77
- />
78
- ) : (
79
- <Controller
80
- control={control}
81
- name="phone"
82
- render={({ field }) => <HawaPhoneInput label="Phone number" />}
83
- rules={{ required: props.texts.phoneRequiredText }}
84
- />
85
- )}
86
- {props.signInType !== "phone" && (
87
- <>
25
+ <Card dir={props.direction}>
26
+ <CardContent headless>
27
+ <form onSubmit={handleSubmit((e) => props.handleSignIn(e))}>
28
+ {props.showError && (
29
+ <HawaAlert
30
+ title={props.errorTitle}
31
+ text={props.errorText}
32
+ severity="error"
33
+ />
34
+ )}
35
+ {props.signInType === "email" ? (
88
36
  <Controller
89
37
  control={control}
90
- name="password"
38
+ name="email"
91
39
  render={({ field }) => (
92
40
  <HawaTextField
93
41
  width="full"
94
- autoComplete="current-password"
95
- type="password"
96
- label={props.texts.passwordLabel}
97
- placeholder={props.texts.passwordPlaceholder}
98
- helpertext={errors.password?.message}
99
- onChange={field.onChange}
42
+ type="text"
43
+ autoComplete="email"
44
+ label={props.texts.emailLabel}
45
+ helpertext={errors.email?.message}
46
+ placeholder={props.texts.emailPlaceholder}
100
47
  value={field.value ?? ""}
48
+ onChange={field.onChange}
101
49
  />
102
50
  )}
103
51
  rules={{
104
- required: props.texts.passwordRequiredText,
105
- minLength: 5,
52
+ required: props.texts.emailRequiredText,
53
+ pattern: {
54
+ value:
55
+ /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
56
+ message: props.texts.emailInvalidText,
57
+ },
106
58
  }}
107
59
  />
108
- {!props.withoutResetPassword && (
109
- <div
110
- onClick={props.handleForgotPassword}
111
- className="mb-3 w-fit cursor-pointer text-xs dark:text-gray-300"
112
- >
113
- {props.texts.forgotPasswordText}
114
- </div>
115
- )}
116
- </>
117
- )}
60
+ ) : props.signInType === "username" ? (
61
+ <Controller
62
+ control={control}
63
+ name="username"
64
+ render={({ field }) => {
65
+ return (
66
+ <HawaTextField
67
+ width="full"
68
+ type="text"
69
+ autoComplete="username"
70
+ label={props.texts.usernameLabel}
71
+ helpertext={errors.username?.message}
72
+ placeholder={props.texts.usernamePlaceholder}
73
+ onChange={field.onChange}
74
+ value={field.value ?? ""}
75
+ />
76
+ )
77
+ }}
78
+ rules={{
79
+ required: props.texts.usernameRequired,
80
+ }}
81
+ />
82
+ ) : (
83
+ <Controller
84
+ control={control}
85
+ name="phone"
86
+ render={({ field }) => <HawaPhoneInput label="Phone number" />}
87
+ rules={{ required: props.texts.phoneRequiredText }}
88
+ />
89
+ )}
90
+ {props.signInType !== "phone" && (
91
+ <>
92
+ <Controller
93
+ control={control}
94
+ name="password"
95
+ render={({ field }) => (
96
+ <HawaTextField
97
+ width="full"
98
+ autoComplete="current-password"
99
+ type="password"
100
+ label={props.texts.passwordLabel}
101
+ placeholder={props.texts.passwordPlaceholder}
102
+ helpertext={errors.password?.message}
103
+ onChange={field.onChange}
104
+ value={field.value ?? ""}
105
+ />
106
+ )}
107
+ rules={{
108
+ required: props.texts.passwordRequiredText,
109
+ minLength: 5,
110
+ }}
111
+ />
112
+ {!props.withoutResetPassword && (
113
+ <div
114
+ onClick={props.handleForgotPassword}
115
+ className="mb-3 w-fit cursor-pointer text-xs dark:text-gray-300"
116
+ >
117
+ {props.texts.forgotPasswordText}
118
+ </div>
119
+ )}
120
+ </>
121
+ )}
118
122
 
119
- {/* <HawaButton
120
- isLoading={props.isLoading}
121
- variant="contained"
122
- color="primary"
123
- size="medium"
124
- width="full"
125
- >
126
- {props.texts.signInText}
127
- </HawaButton> */}
128
- <Button className="w-full">{props.texts.signInText}</Button>
129
- {!props.withoutSignUp && (
130
- <div className="p-3 text-center text-sm font-semibold dark:text-gray-300">
131
- {props.texts.newUserText}{" "}
132
- <span
133
- onClick={props.handleRouteToSignUp}
134
- className="cursor-pointer text-blue-600 dark:text-blue-400"
135
- >
136
- {props.texts.signUpText}
137
- </span>
138
- </div>
139
- )}
140
- </form>
141
123
 
142
- {/* <div className="grid grid-cols-2 gap-6">
143
- <Button variant="outline">
144
- <FaGithub className="mr-2 h-4 w-4" /> Github
145
- </Button>
146
- <Button variant="outline">
147
- <FaGoogle className="mr-2 h-4 w-4" /> Google
148
- </Button>
149
- </div>
150
- <div className="relative">
151
- <div className="absolute inset-0 flex items-center">
152
- <span className="w-full border-t" />
153
- </div>
154
- <div className="relative flex justify-center text-xs uppercase">
155
- <span className="bg-background px-2 text-muted-foreground">
156
- Or continue with
157
- </span>
158
- </div>
159
- </div> */}
124
+ <Button className="w-full" isLoading={props.isLoading}>
125
+ {props.texts.signInText}
126
+ </Button>
127
+ {!props.withoutSignUp && (
128
+ <div className="p-3 text-center text-sm font-semibold dark:text-gray-300">
129
+ {props.texts.newUserText}{" "}
130
+ <span
131
+ onClick={props.handleRouteToSignUp}
132
+ className="cursor-pointer text-blue-600 dark:text-blue-400"
133
+ >
134
+ {props.texts.createAccount}
135
+ </span>
136
+ </div>
137
+ )}
138
+ </form>
139
+ </CardContent>
140
+
160
141
  {/* 3rd Party Sign Auth Buttons */}
161
142
  {props.viaGithub || props.viaGoogle || props.viaTwitter ? (
162
- <div className="flex flex-col ">
143
+ <CardFooter className="grid grid-cols-1 gap-2 ">
163
144
  {props.viaGoogle && (
164
- <HawaLogoButton
165
- logo="google"
166
- direction={props.direction}
167
- buttonText={props.texts.signInViaGoogleLabel}
168
- onClick={props.handleGoogleSignIn}
169
- />
145
+ <Button variant="outline" onClick={props.handleGoogleSignIn}>
146
+ <Icons.google
147
+ className={clsx(
148
+ "h-4 w-4",
149
+ props.direction === "rtl" ? "ml-2" : "mr-2"
150
+ )}
151
+ />
152
+ {props.texts.signInViaGoogleLabel}
153
+ </Button>
170
154
  )}
171
155
  {props.viaGithub && (
172
- <HawaLogoButton
173
- logo="github"
174
- direction={props.direction}
175
- buttonText={props.texts.signInViaGithubLabel}
176
- onClick={props.handleGithubSignIn}
177
- />
156
+ <Button variant="outline" onClick={props.handleGithubSignIn}>
157
+ <Icons.gitHub
158
+ className={clsx(
159
+ "h-4 w-4",
160
+ props.direction === "rtl" ? "ml-2" : "mr-2"
161
+ )}
162
+ />
163
+ {props.texts.signInViaGithubLabel}
164
+ </Button>
178
165
  )}
179
166
  {props.viaTwitter && (
180
- <HawaLogoButton
181
- logo="twitter"
182
- direction={props.direction}
183
- buttonText={props.texts.signInViaTwitterLabel}
184
- onClick={props.handleTwitterSignIn}
185
- />
167
+ <Button variant="outline" onClick={props.handleTwitterSignIn}>
168
+ <Icons.twitter
169
+ className={clsx(
170
+ "h-4 w-4",
171
+ props.direction === "rtl" ? "ml-2" : "mr-2"
172
+ )}
173
+ />
174
+ {props.texts.signInViaTwitterLabel}
175
+ </Button>
186
176
  )}
187
- </div>
177
+ </CardFooter>
188
178
  ) : null}
189
- </HawaContainer>
179
+ </Card>
190
180
  )
191
181
  }
192
182
 
@@ -210,7 +200,7 @@ type SignInFormTypes = {
210
200
  passwordRequiredText?: string
211
201
  forgotPasswordText?: string
212
202
  newUserText?: string
213
- signUpText?: string
203
+ createAccount?: string
214
204
  signInText?: string
215
205
  signInViaGoogleLabel?: string
216
206
  signInViaGithubLabel?: string