@sikka/hawa 0.0.241 → 0.0.242

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.0.241",
3
+ "version": "0.0.242",
4
4
  "description": "SaaS Oriented UI Kit",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.es.js",
@@ -1,4 +1,4 @@
1
- import React, { FunctionComponent, ReactNode, useState, useEffect } from "react"
1
+ import React, { FunctionComponent, useState, useEffect } from "react"
2
2
  import { clsx } from "clsx"
3
3
 
4
4
  type ComponentTypes = {
@@ -33,7 +33,7 @@ export const BackToTop: FunctionComponent<ComponentTypes> = ({ ...props }) => {
33
33
  props.anchor.current.addEventListener("scroll", onScroll)
34
34
 
35
35
  return () => {
36
- props.anchor.current.removeEventListener("scroll", onScroll)
36
+ props.anchor.current?.removeEventListener("scroll", onScroll)
37
37
  }
38
38
  }, [])
39
39
 
@@ -72,14 +72,26 @@ export const BackToTop: FunctionComponent<ComponentTypes> = ({ ...props }) => {
72
72
  return (
73
73
  <div
74
74
  className={clsx(
75
- "fixed rounded bg-blue-300 p-2 text-black transition-all hover:bg-blue-500",
76
- `${visible ? "block" : "hidden"}`
77
- // getClasses()
75
+ "fixed w-fit rounded bg-blue-300 p-2 text-black transition-all hover:bg-blue-500 ",
76
+ `${visible ? "inline-block" : "hidden"}`
78
77
  )}
79
78
  style={getStyles()}
80
79
  onClick={backToTop}
81
80
  >
82
- Back to top
81
+ {/* Back to top arrow 👇*/}
82
+ <svg
83
+ className={clsx(
84
+ "h-6 w-6 shrink-0 rotate-180 transition-all disabled:bg-gray-200"
85
+ )}
86
+ viewBox="0 0 20 20"
87
+ xmlns="http://www.w3.org/2000/svg"
88
+ >
89
+ <path
90
+ fillRule="evenodd"
91
+ d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
92
+ clipRule="evenodd"
93
+ ></path>
94
+ </svg>
83
95
  </div>
84
96
  )
85
97
  }
@@ -1,4 +1,4 @@
1
- import React from "react"
1
+ import React, { useRef, useState, useEffect } from "react"
2
2
  import clsx from "clsx"
3
3
  import { HawaButton } from "./HawaButton"
4
4
 
@@ -8,6 +8,8 @@ type AlertTypes = {
8
8
  title?: any
9
9
  /** The text of the alert placed below the title of the alert. Can be used alone */
10
10
  text: any
11
+ /** The duration for the alert to stay on the screen */
12
+ duration?: number
11
13
  // hideIcon?: any //TODO: an X button to delete the alert
12
14
  variant?:
13
15
  | "normal"
@@ -28,8 +30,31 @@ type AlertTypes = {
28
30
  export const HawaAlert: React.FunctionComponent<AlertTypes> = ({
29
31
  variant = "normal",
30
32
  direction = "ltr",
33
+ duration,
31
34
  ...props
32
35
  }) => {
36
+ const alertRef = useRef(null)
37
+ const [closed, setClosed] = useState(false)
38
+
39
+ useEffect(() => {
40
+ if (duration) {
41
+ //To change opacity and hide the component
42
+ const timeoutHide = setTimeout(() => {
43
+ setClosed(true)
44
+ }, duration)
45
+ //To destroy the component after hiding it
46
+ const timeoutDestroy = setTimeout(() => {
47
+ setClosed(true)
48
+ alertRef.current.removeChild(alertRef.current.children[0])
49
+ }, duration + 1000)
50
+
51
+ return () => {
52
+ clearTimeout(timeoutHide)
53
+ clearTimeout(timeoutDestroy)
54
+ }
55
+ }
56
+ }, [duration])
57
+
33
58
  let styleVariant = {
34
59
  normal: {
35
60
  info: "text-blue-700 bg-blue-100 dark:bg-blue-200 dark:text-blue-800",
@@ -77,30 +102,58 @@ export const HawaAlert: React.FunctionComponent<AlertTypes> = ({
77
102
  },
78
103
  }
79
104
  return (
80
- <div
81
- className={clsx(
82
- "mb-4 flex flex-col rounded p-4 text-sm",
83
- styleVariant[variant][props.severity]
84
- )}
85
- role="alert"
86
- dir={direction}
87
- >
88
- <span className="font-medium">{props.title}</span>
89
- <span>{" " + props.text}</span>
90
- {props.actions && (
91
- <div className="mt-2 flex flex-row gap-2">
92
- {props.actions.map((act, index) => (
93
- <HawaButton
94
- key={index}
95
- variant={act.variant}
96
- onClick={act.onClick()}
97
- margins="none"
98
- >
99
- {act.label}
100
- </HawaButton>
101
- ))}
102
- </div>
103
- )}
105
+ <div ref={alertRef}>
106
+ <div
107
+ className={clsx(
108
+ "mb-4 flex flex-col rounded p-4 text-sm",
109
+ styleVariant[variant][props.severity],
110
+ closed ? "opacity-0" : "opacity-100"
111
+ )}
112
+ role="alert"
113
+ dir={direction}
114
+ >
115
+ <span className="font-medium">{props.title}</span>
116
+ <span>{" " + props.text}</span>
117
+ {props.actions && (
118
+ <div className="mt-2 flex flex-row gap-2">
119
+ {props.actions.map((act, index) => (
120
+ <HawaButton
121
+ key={index}
122
+ variant={act.variant}
123
+ onClick={act.onClick()}
124
+ margins="none"
125
+ >
126
+ {act.label}
127
+ </HawaButton>
128
+ ))}
129
+ </div>
130
+ )}
131
+ <button
132
+ type="button"
133
+ className="absolute right-8 inline-flex h-8 w-8 rounded p-1.5 text-gray-400 hover:bg-gray-100 hover:text-gray-900 focus:ring-2 focus:ring-gray-300 dark:bg-gray-800 dark:text-gray-500 dark:hover:bg-gray-700 dark:hover:text-white"
134
+ data-dismiss-target="#alert-default"
135
+ aria-label="Close"
136
+ onClick={() => {
137
+ setClosed(true)
138
+ alertRef.current.removeChild(alertRef.current.children[0])
139
+ }}
140
+ >
141
+ <span className="sr-only">Close</span>
142
+ <svg
143
+ aria-hidden="true"
144
+ className="h-5 w-5"
145
+ fill="currentColor"
146
+ viewBox="0 0 20 20"
147
+ xmlns="http://www.w3.org/2000/svg"
148
+ >
149
+ <path
150
+ fillRule="evenodd"
151
+ d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
152
+ clipRule="evenodd"
153
+ ></path>
154
+ </svg>
155
+ </button>
156
+ </div>
104
157
  </div>
105
158
  )
106
159
  }
@@ -6,7 +6,7 @@ type THawaSnackBar = {
6
6
  severity: "info" | "warning" | "error" | "success" | "none"
7
7
  title: string
8
8
  description: string
9
- handleClose?: () => void
9
+ // handleClose?: () => void
10
10
  duration?: number
11
11
  position?:
12
12
  | "top-left"
@@ -31,7 +31,7 @@ export const HawaSnackbar: FC<THawaSnackBar> = ({
31
31
  severity = "info",
32
32
  position = "bottom-left",
33
33
  actions,
34
- handleClose,
34
+ // handleClose,
35
35
  duration,
36
36
  }) => {
37
37
  let defaultStyle =
@@ -50,9 +50,9 @@ export const HawaTextField: React.FunctionComponent<TextFieldTypes> = ({
50
50
 
51
51
  let defaultStyle = "flex max-h-fit flex-col justify-center"
52
52
  let defaultInputStyle =
53
- "block w-full rounded border border-gray-300 bg-white p-2 text-sm text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-blue-500 dark:focus:ring-blue-500"
53
+ "block w-full rounded outline outline-gray-300 bg-white p-2 text-sm text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-blue-500 dark:focus:ring-blue-500"
54
54
  let previewInputStyle =
55
- "block w-full rounded bg-gray-50 h-9 p-2 text-sm text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-blue-500 dark:focus:ring-blue-500"
55
+ "block w-full rounded bg-gray-50 p-2 text-sm text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-blue-500 dark:focus:ring-blue-500"
56
56
  // "mb-0 block w-full rounded border border-gray-300 bg-gray-50 p-2 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-blue-500 dark:focus:ring-blue-500",
57
57
 
58
58
  return (
@@ -89,16 +89,17 @@ export const HawaTextField: React.FunctionComponent<TextFieldTypes> = ({
89
89
  {props.icon}
90
90
  </div>
91
91
  )}
92
- {/* <input
92
+ <input
93
93
  {...props}
94
+ disabled={preview}
94
95
  className={clsx(previewInputStyle, props.icon ? "pl-10" : "")}
95
- /> */}
96
- <div
96
+ />
97
+ {/* <div
97
98
  // {...props}
98
99
  className={clsx(previewInputStyle, props.icon ? "pl-10" : "")}
99
100
  >
100
101
  {props.value}
101
- </div>
102
+ </div> */}
102
103
  </div>
103
104
  )}
104
105
  </>
package/src/styles.css CHANGED
@@ -636,6 +636,9 @@ video {
636
636
  .right-4 {
637
637
  right: 1rem;
638
638
  }
639
+ .right-8 {
640
+ right: 2rem;
641
+ }
639
642
  .top-0 {
640
643
  top: 0px;
641
644
  }
@@ -898,6 +901,9 @@ video {
898
901
  .h-6 {
899
902
  height: 1.5rem;
900
903
  }
904
+ .h-64 {
905
+ height: 16rem;
906
+ }
901
907
  .h-7 {
902
908
  height: 1.75rem;
903
909
  }
@@ -964,6 +970,9 @@ video {
964
970
  .w-1\/3 {
965
971
  width: 33.333333%;
966
972
  }
973
+ .w-1\/4 {
974
+ width: 25%;
975
+ }
967
976
  .w-10 {
968
977
  width: 2.5rem;
969
978
  }
@@ -982,6 +991,9 @@ video {
982
991
  .w-2\/3 {
983
992
  width: 66.666667%;
984
993
  }
994
+ .w-2\/4 {
995
+ width: 50%;
996
+ }
985
997
  .w-20 {
986
998
  width: 5rem;
987
999
  }
@@ -1621,10 +1633,6 @@ video {
1621
1633
  --tw-bg-opacity: 1;
1622
1634
  background-color: rgb(185 28 28 / var(--tw-bg-opacity));
1623
1635
  }
1624
- .bg-red-900 {
1625
- --tw-bg-opacity: 1;
1626
- background-color: rgb(127 29 29 / var(--tw-bg-opacity));
1627
- }
1628
1636
  .bg-slate-600 {
1629
1637
  --tw-bg-opacity: 1;
1630
1638
  background-color: rgb(71 85 105 / var(--tw-bg-opacity));