@sikka/hawa 0.2.4-beta → 0.2.5-beta

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/dist/styles.css CHANGED
@@ -388,7 +388,8 @@ video {
388
388
  :root {
389
389
  --background: 0 0% 100%;
390
390
  --foreground: 240 10% 3.9%;
391
- --card: 0 0% 100%;
391
+ /* --card: 0 0% 100%; */
392
+ --card: 210 50% 98%;
392
393
  --card-foreground: 240 10% 3.9%;
393
394
  --popover: 0 0% 100%;
394
395
  --popover-foreground: 240 10% 3.9%;
@@ -422,7 +423,7 @@ video {
422
423
  --border: 240 5.9% 90%;
423
424
  --input: 240 5.9% 90%;
424
425
  --ring: 240 5% 64.9%;
425
- --radius: 1rem;
426
+ --radius: 0.5rem;
426
427
  --radius-inner: calc(var(--radius) - calc(var(--radius) / 3));
427
428
 
428
429
  --layout-primary-700: #b7aff7;
@@ -445,7 +446,8 @@ video {
445
446
  --layout-primary-300: #4a4a4a;
446
447
  --background: 240 10% 3.9%;
447
448
  --foreground: 0 0% 98%;
448
- --card: 240 10% 3.9%;
449
+ /* --card: 240 10% 3.9%; */
450
+ --card: 0 0% 2%;
449
451
  --card-foreground: 0 0% 98%;
450
452
  --popover: 240 10% 3.9%;
451
453
  --popover-foreground: 0 0% 98%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.2.4-beta",
3
+ "version": "0.2.5-beta",
4
4
  "description": "Modern UI Kit made with Tailwind & Radix Primitives",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,8 +1,9 @@
1
1
  import React, { useState, FC } from "react"
2
2
  import { Controller, useForm } from "react-hook-form"
3
- import { HawaPhoneInput } from "../../elements"
3
+ import { HawaPhoneInput, HawaPinInput } from "../../elements"
4
4
  import { Card, CardContent } from "../../elements/Card"
5
5
  import { Button } from "../../elements/Button"
6
+ import { cn } from "../../util"
6
7
 
7
8
  type SignInPhoneTypes = {
8
9
  value: any
@@ -12,45 +13,147 @@ type SignInPhoneTypes = {
12
13
  handlePhoneChange: any
13
14
  phoneRequiredText: any
14
15
  SignInButtonText: any
15
- handleSignIn: any
16
+ handleContinue: any
17
+ handleConfirm: any
18
+ loadingContinue?: boolean
19
+ loadingConfirm?: boolean
20
+ confirmationStage?: boolean
21
+ texts?: {
22
+ didntGetCode?: string
23
+ resendCode?: string
24
+ cancel?: string
25
+ confirm?: string
26
+ continue?: string
27
+ }
16
28
  }
17
29
 
18
30
  export const SignInPhone: FC<SignInPhoneTypes> = (props) => {
31
+ const [pins, setPins] = useState(null)
32
+
19
33
  const methods = useForm()
20
34
  const {
21
35
  formState: { errors },
22
36
  handleSubmit,
23
37
  control,
24
38
  } = methods
39
+ const [resendTimer, setResendTimer] = useState(null)
40
+ const [remainingTime, setRemainingTime] = useState(0)
41
+ const [showResendTimer, setShowResendTimer] = useState(false)
25
42
 
26
43
  const [userPhone, setUserPhone] = useState("")
44
+ const [phoneConfirm, setPhoneConfirm] = useState(props.confirmationStage)
45
+
46
+ const startResendTimer = () => {
47
+ // Clear any existing timer
48
+ clearTimeout(resendTimer)
49
+
50
+ // Set the timer duration (e.g., 60 seconds)
51
+ const timerDuration = 60
52
+ setRemainingTime(timerDuration)
53
+ setShowResendTimer(true)
54
+
55
+ const newTimer = setInterval(() => {
56
+ setRemainingTime((prevTime) => {
57
+ if (prevTime > 0) {
58
+ return prevTime - 1;
59
+ } else {
60
+ clearInterval(newTimer); // Stop the timer when it reaches zero
61
+ setShowResendTimer(false);
62
+ return 0;
63
+ }
64
+ });
65
+ }, 1000);
66
+
67
+ // Update the state with the new timer
68
+ setResendTimer(newTimer)
69
+
70
+ // Add logic to resend OTP here if needed
71
+ }
72
+
27
73
  return (
28
74
  <Card>
29
- <CardContent headless>
30
- <form
31
- onSubmit={(e) => {
32
- e.preventDefault()
33
- props.handleSignIn(userPhone)
34
- }}
35
- >
36
- <Controller
37
- control={control}
38
- name="phone"
39
- render={({ field }) => (
40
- <HawaPhoneInput
41
- country={props.country ?? ""}
42
- label={props.label ?? ""}
43
- handleChange={(e: any) => setUserPhone(e.target.value)}
44
- {...field}
45
- />
46
- )}
47
- rules={{
48
- required: props.phoneRequiredText,
75
+ <CardContent className="transition-all" headless>
76
+ {phoneConfirm ? (
77
+ <form
78
+ onSubmit={(e) => {
79
+ e.preventDefault()
80
+ if (pins) {
81
+ props.handleConfirm(pins)
82
+ }
83
+ }}
84
+ >
85
+ <HawaPinInput width="full" digits={6} getPins={(e) => setPins(e)} />
86
+ <div className=" py-2 text-center text-xs text-muted-foreground">
87
+ {showResendTimer ? (
88
+ <span>
89
+ Resend code in {remainingTime} seconds |{" "}
90
+ <span
91
+ className="clickable-link"
92
+ onClick={() => {
93
+ clearTimeout(resendTimer)
94
+ setShowResendTimer(false)
95
+ // Add logic to resend OTP here
96
+ }}
97
+ >
98
+ Cancel
99
+ </span>
100
+ </span>
101
+ ) : (
102
+ <span>
103
+ {props.texts?.didntGetCode ?? "Didn't get the code?"}{" "}
104
+ <span
105
+ className="clickable-link"
106
+ onClick={() => {
107
+ startResendTimer()
108
+ // Add logic to resend OTP here
109
+ }}
110
+ >
111
+ {props.texts?.resendCode ?? "Click to resend"}
112
+ </span>
113
+ </span>
114
+ )}
115
+ </div>
116
+
117
+ <div className="mt-4 grid grid-cols-2 gap-2">
118
+ <Button
119
+ variant="secondary"
120
+ onClick={() => setPhoneConfirm(false)}
121
+ >
122
+ {props.texts?.cancel ?? "Cancel"}
123
+ </Button>
124
+ <Button isLoading={props.loadingConfirm}>
125
+ {props.texts?.confirm ?? "Confirm"}
126
+ </Button>
127
+ </div>
128
+ </form>
129
+ ) : (
130
+ <form
131
+ onSubmit={(e) => {
132
+ e.preventDefault()
133
+ setPhoneConfirm(true)
134
+ props.handleContinue(userPhone)
49
135
  }}
50
- />
51
- <div className="mt-2"></div>
52
- <Button className="w-full">{props.SignInButtonText}</Button>
53
- </form>
136
+ >
137
+ <Controller
138
+ control={control}
139
+ name="phone"
140
+ render={({ field }) => (
141
+ <HawaPhoneInput
142
+ country={props.country ?? ""}
143
+ label={props.label ?? ""}
144
+ handleChange={(e: any) => setUserPhone(e.target.value)}
145
+ {...field}
146
+ />
147
+ )}
148
+ rules={{
149
+ required: props.phoneRequiredText,
150
+ }}
151
+ />
152
+ <Button isLoading={props.loadingContinue} className="w-full">
153
+ {props.texts?.continue ?? "Continue"}
154
+ </Button>
155
+ </form>
156
+ )}
54
157
  </CardContent>
55
158
  </Card>
56
159
  )
package/src/styles.css CHANGED
@@ -388,7 +388,8 @@ video {
388
388
  :root {
389
389
  --background: 0 0% 100%;
390
390
  --foreground: 240 10% 3.9%;
391
- --card: 0 0% 100%;
391
+ /* --card: 0 0% 100%; */
392
+ --card: 210 50% 98%;
392
393
  --card-foreground: 240 10% 3.9%;
393
394
  --popover: 0 0% 100%;
394
395
  --popover-foreground: 240 10% 3.9%;
@@ -422,7 +423,7 @@ video {
422
423
  --border: 240 5.9% 90%;
423
424
  --input: 240 5.9% 90%;
424
425
  --ring: 240 5% 64.9%;
425
- --radius: 1rem;
426
+ --radius: 0.5rem;
426
427
  --radius-inner: calc(var(--radius) - calc(var(--radius) / 3));
427
428
 
428
429
  --layout-primary-700: #b7aff7;
@@ -445,7 +446,8 @@ video {
445
446
  --layout-primary-300: #4a4a4a;
446
447
  --background: 240 10% 3.9%;
447
448
  --foreground: 0 0% 98%;
448
- --card: 240 10% 3.9%;
449
+ /* --card: 240 10% 3.9%; */
450
+ --card: 0 0% 2%;
449
451
  --card-foreground: 0 0% 98%;
450
452
  --popover: 240 10% 3.9%;
451
453
  --popover-foreground: 0 0% 98%;
package/src/tailwind.css CHANGED
@@ -54,7 +54,8 @@
54
54
  :root {
55
55
  --background: 0 0% 100%;
56
56
  --foreground: 240 10% 3.9%;
57
- --card: 0 0% 100%;
57
+ /* --card: 0 0% 100%; */
58
+ --card: 210 50% 98%;
58
59
  --card-foreground: 240 10% 3.9%;
59
60
  --popover: 0 0% 100%;
60
61
  --popover-foreground: 240 10% 3.9%;
@@ -88,7 +89,7 @@
88
89
  --border: 240 5.9% 90%;
89
90
  --input: 240 5.9% 90%;
90
91
  --ring: 240 5% 64.9%;
91
- --radius: 1rem;
92
+ --radius: 0.5rem;
92
93
  --radius-inner: calc(var(--radius) - calc(var(--radius) / 3));
93
94
 
94
95
  --layout-primary-700: #b7aff7;
@@ -111,7 +112,8 @@
111
112
  --layout-primary-300: #4a4a4a;
112
113
  --background: 240 10% 3.9%;
113
114
  --foreground: 0 0% 98%;
114
- --card: 240 10% 3.9%;
115
+ /* --card: 240 10% 3.9%; */
116
+ --card: 0 0% 2%;
115
117
  --card-foreground: 0 0% 98%;
116
118
  --popover: 240 10% 3.9%;
117
119
  --popover-foreground: 0 0% 98%;