@sikka/hawa 0.0.163 → 0.0.165

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.163",
3
+ "version": "0.0.165",
4
4
  "description": "UI Kit",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.es.js",
@@ -7,16 +7,18 @@ type TabsTypes = {
7
7
  defaultValue?: any
8
8
  contents?: any
9
9
  orientation?: "horizontal" | "vertical"
10
+ direction?: "rtl" | "ltr"
10
11
  }
11
12
  export const HawaTabs: React.FunctionComponent<TabsTypes> = ({
12
13
  orientation = "horizontal",
14
+ direction = "ltr",
13
15
  ...props
14
16
  }) => {
15
17
  const [selectedOption, setSelectedOption] = useState(props.options[0]?.value)
16
18
  // const [selectedOption, setSelectedOption] = useState(props.defaultValue - 1)
17
19
  let activeTabStyle = {
18
20
  vertical:
19
- "inline-block py-2 px-4 text-white bg-buttonPrimary-default rounded-lg rounded-tl-none rounded-bl-none active",
21
+ "inline-block py-2 px-4 text-white bg-buttonPrimary-default active",
20
22
  horizontal:
21
23
  "inline-block py-2 px-4 text-white bg-buttonPrimary-default rounded-lg rounded-br-none rounded-bl-none active",
22
24
  }
@@ -44,12 +46,13 @@ export const HawaTabs: React.FunctionComponent<TabsTypes> = ({
44
46
  }
45
47
  let tabsStyle = {
46
48
  vertical:
47
- "flex flex-col w-fit flex-wrap rounded-lg border-b-primary-500 bg-gray-100 text-center text-sm font-medium text-gray-500 dark:text-gray-400",
49
+ "sticky top-2 h-fit flex flex-col w-fit flex-wrap rounded-lg border-b-primary-500 bg-gray-100 text-center text-sm font-medium text-gray-500 dark:text-gray-400",
48
50
  horizontal:
49
51
  "flex w-fit flex-wrap rounded-lg rounded-br-none rounded-bl-none border-b-primary-500 bg-gray-100 text-center text-sm font-medium text-gray-500 dark:text-gray-400",
50
52
  }
51
53
  return (
52
54
  <div
55
+ dir={direction}
53
56
  className={clsx(
54
57
  containerStyle[orientation],
55
58
  props.options[selectedOption] ? "border-b-2" : "border-b-0"
@@ -58,9 +61,24 @@ export const HawaTabs: React.FunctionComponent<TabsTypes> = ({
58
61
  <ul
59
62
  className={clsx(
60
63
  tabsStyle[orientation],
61
- props.options[selectedOption] ? "border-b-2" : "border-b-0"
64
+ "border-buttonPrimary-default",
65
+ orientation === "vertical"
66
+ ? direction === "rtl"
67
+ ? "rounded-none rounded-r-lg border-l-2"
68
+ : "rounded-none rounded-l-lg border-r-2"
69
+ : "border-b-2"
62
70
  )}
63
71
  >
72
+ {/*
73
+ if selected option
74
+ if vertical
75
+ if rtl
76
+ border left
77
+ else
78
+ border right
79
+ else
80
+ border bottom
81
+ */}
64
82
  {props.options?.map((opt: any, o) => (
65
83
  <li key={o}>
66
84
  <button
@@ -72,9 +90,13 @@ export const HawaTabs: React.FunctionComponent<TabsTypes> = ({
72
90
  className={clsx(
73
91
  opt.value === selectedOption
74
92
  ? // props.options[selectedOption].value === opt.value
75
- activeTabStyle[orientation]
93
+ [
94
+ activeTabStyle[orientation],
95
+ direction === "rtl" ? "rounded-r-lg" : "rounded-l-lg",
96
+ ]
76
97
  : inactiveTabStyle[orientation],
77
- "transition-all"
98
+ "w-full transition-all"
99
+ // direction === "rtl" ? "bg-yellow-400" : "bg-yellow-400"
78
100
  )}
79
101
  >
80
102
  {opt.label}
@@ -87,7 +109,7 @@ export const HawaTabs: React.FunctionComponent<TabsTypes> = ({
87
109
  {props.options.map((tab) => (
88
110
  <div
89
111
  key={tab.value}
90
- className={`${selectedOption === tab.value ? "" : "hidden"}`}
112
+ className={clsx(selectedOption === tab.value ? "" : "hidden")}
91
113
  >
92
114
  {tab.content}
93
115
  </div>
@@ -1 +1 @@
1
- export * from "./useDiscloser"
1
+ export * from "./useDiscloser"
@@ -0,0 +1,30 @@
1
+ import { useState, useEffect, useRef } from "react";
2
+
3
+ function useScrollPosition(ref) {
4
+ const [scrollPosition, setScrollPosition] = useState(0);
5
+ // const savedRef = useRef();
6
+
7
+ // useEffect(() => {
8
+ // savedRef.current = ref;
9
+ // }, [ref]);
10
+
11
+ useEffect(() => {
12
+ function handleScroll() {
13
+ setScrollPosition(ref.current.scrollTop);
14
+ }
15
+
16
+ if (ref.current) {
17
+ ref.current.addEventListener("scroll", handleScroll);
18
+ }
19
+
20
+ return () => {
21
+ if (ref.current) {
22
+ ref.current.removeEventListener("scroll", handleScroll);
23
+ }
24
+ };
25
+ }, [ref]);
26
+
27
+ return scrollPosition;
28
+ }
29
+
30
+ export default useScrollPosition;
@@ -40,6 +40,7 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = ({
40
40
  const [openSubItem, setOpenSubItem] = useState(false)
41
41
  const { isOpen, onClose, onOpen } = useDiscloser(false)
42
42
  const ref = useRef(null)
43
+ const drawerItemRef = useRef(null)
43
44
 
44
45
  let size
45
46
  if (typeof window !== "undefined") {
@@ -48,11 +49,11 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = ({
48
49
  size = 1200
49
50
  }
50
51
  const [keepOpen, setKeepOpen] = useState(false)
51
- // console.log("size is ", size)
52
52
  useEffect(() => {
53
53
  const handleClickOutside = (event) => {
54
54
  if (ref.current && !ref.current.contains(event.target) && !keepOpen) {
55
55
  // onClickOutside && onClickOutside()
56
+
56
57
  setOpenSideMenu(false)
57
58
  }
58
59
  }
@@ -68,12 +69,12 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = ({
68
69
  //less than 600
69
70
  //as nothing and expands as button is clicked
70
71
  let ltrDrawerStyle = [
71
- "fixed top-0 left-0 z-40 flex h-full flex-col justify-between overflow-x-clip bg-layoutPrimary-default transition-all hover:overflow-auto",
72
+ "fixed top-0 left-0 z-40 flex h-full flex-col justify-between overflow-x-clip bg-layoutPrimary-default transition-all",
72
73
  size > 600 ? "w-14 hover:w-40" : "w-0",
73
74
  openSideMenu ? "w-40" : "w-14",
74
75
  ]
75
76
  let rtlDrawerStyle = [
76
- "fixed top-0 right-0 z-40 flex h-full flex-col justify-between overflow-x-clip bg-layoutPrimary-default transition-all hover:overflow-auto",
77
+ "fixed top-0 right-0 z-40 flex h-full flex-col justify-between overflow-x-clip bg-layoutPrimary-default transition-all",
77
78
  size > 600 ? "w-14 hover:w-40" : "w-0",
78
79
  openSideMenu ? "w-40" : "w-14",
79
80
  ]
@@ -154,28 +155,28 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = ({
154
155
  </div>
155
156
  )}
156
157
  <div
157
- onMouseEnter={() => setOpenSideMenu(true)}
158
- onMouseLeave={() =>
159
- keepOpen ? setOpenSideMenu(true) : setOpenSideMenu(false)
160
- }
158
+ onMouseEnter={() => {
159
+ setOpenSideMenu(true)
160
+ }}
161
+ onMouseLeave={() => {
162
+ if (keepOpen) {
163
+ setOpenSideMenu(true)
164
+ } else {
165
+ setOpenSideMenu(false)
166
+ }
167
+ }}
161
168
  ref={ref}
162
- className={clsx(
163
- direction === "rtl" ? rtlDrawerStyle : ltrDrawerStyle
164
- // "fixed top-0 left-0 z-50 flex h-full flex-col justify-between overflow-x-clip bg-layoutPrimary-default transition-all hover:overflow-auto",
165
- // size > 600 ? "w-14 hover:w-40" : "w-0",
166
- // openSideMenu ? "w-40" : "w-14"
167
- )}
169
+ className={clsx(direction === "rtl" ? rtlDrawerStyle : ltrDrawerStyle)}
168
170
  >
169
- <div>
171
+ <div className="overflow-scroll scroll-auto ">
170
172
  <div
171
173
  className={clsx(
172
- "fixed z-50 mb-2 flex h-12 items-center justify-center bg-layoutPrimary-default p-2",
174
+ "fixed z-50 mb-2 flex h-12 items-center justify-center bg-layoutPrimary-default p-2 transition-all",
173
175
  openSideMenu ? "w-full" : "w-14"
174
176
  )}
175
177
  >
176
178
  <img
177
179
  className={clsx(
178
- // "bg-blue-700",
179
180
  "fixed top-2 h-9",
180
181
  direction === "rtl" ? "right-2.5" : "left-2.5",
181
182
  !openSideMenu ? "invisible" : "visible"
@@ -198,22 +199,26 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = ({
198
199
  ) : null}
199
200
  </div>
200
201
 
201
- <div className="mt-12">
202
+ <div className="mt-12 mb-8">
202
203
  {props.drawerItems.map((dSection, j) => (
203
204
  <div
204
205
  key={j}
205
- className={clsx(
206
- "flex flex-col items-stretch justify-center"
207
- // !openSideMenu ? "invisible" : "visible"
208
- )}
206
+ className={clsx("flex flex-col items-stretch justify-center")}
209
207
  >
210
208
  {dSection.map((dItem, i) => {
211
209
  return (
212
- <div className="flex flex-col">
210
+ <div key={i} id={"test"} className="flex flex-col">
213
211
  <div
214
- key={i}
212
+ ref={
213
+ props.currentPage === dItem.slug
214
+ ? drawerItemRef
215
+ : null
216
+ }
215
217
  onClick={() => {
216
218
  // if()
219
+ const { offsetTop } = drawerItemRef.current
220
+ ref.current.scrollTop = offsetTop - 100
221
+
217
222
  dItem.action()
218
223
  }}
219
224
  className={clsx(
@@ -260,41 +265,46 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = ({
260
265
  </div>
261
266
  </div>
262
267
  <div
268
+ dir={direction}
263
269
  className={clsx(
264
- "sticky bottom-2 flex w-fit items-center",
265
- direction === "rtl" ? "left-2 justify-start" : " justify-end"
270
+ "fixed bottom-2 flex w-fit items-center",
271
+ direction === "rtl"
272
+ ? "right-32 justify-start"
273
+ : "left-32 justify-start",
274
+ "transition-all duration-700",
275
+ openSideMenu && size > 600 ? " opacity-100" : " opacity-0"
266
276
  )}
267
277
  >
268
278
  {openSideMenu && !keepOpen && size > 600 ? (
269
279
  <div
270
- onClick={() => setKeepOpen(true)}
280
+ onClick={() => setKeepOpen(!keepOpen)}
271
281
  className={clsx(
272
- "w-fit cursor-pointer rounded-lg bg-gray-300 p-2"
273
- // openSideMenu ? "sticky bottom-2" : ""
282
+ keepOpen ? "rotate-180" : "",
283
+ direction === "rtl" ? "rotate-180" : "",
284
+ "w-fit cursor-pointer rounded-lg bg-gray-300 p-1 transition-all"
274
285
  )}
275
286
  >
276
287
  <FaChevronRight />
277
288
  </div>
278
289
  ) : null}
279
- {keepOpen && (
290
+ {/* {keepOpen && (
280
291
  <div
281
292
  onClick={() => setKeepOpen(false)}
282
- className=" w-fit rotate-180 cursor-pointer rounded-lg bg-gray-300 p-2"
293
+ className={clsx(
294
+ openSideMenu ? "visible" : "invisible",
295
+ direction === "rtl" ? "rotate-180" : "",
296
+ "w-fit cursor-pointer rounded-lg bg-gray-300 p-1 transition-all"
297
+ )}
283
298
  >
284
- <FaChevronRight />
299
+ <FaChevronLeft />
285
300
  </div>
286
- )}
301
+ )} */}
287
302
  </div>
288
303
  </div>
289
304
 
290
305
  <div
291
306
  className={clsx(
292
307
  direction === "rtl" ? rtlChildrenStyle : ltrChildrenStyle
293
- // "fixed h-full overflow-y-auto",
294
- // size > 600 ? "left-14 w-[calc(100%-3.5rem)]" : "left-0 ",
295
- // props.topBar ? "top-14" : "top-0",
296
- // keepOpen ? "left-40 w-[calc(100%-10rem)]" : "",
297
- // keepOpen && size > 600 ? "left-0 w-[calc(100%-10.01rem)]" : ""
298
308
  )}
299
309
  >
300
310
  {props.children}
package/src/styles.css CHANGED
@@ -605,6 +605,9 @@ video {
605
605
  .bottom-4 {
606
606
  bottom: 1rem;
607
607
  }
608
+ .top-2 {
609
+ top: 0.5rem;
610
+ }
608
611
  .left-3 {
609
612
  left: 0.75rem;
610
613
  }
@@ -629,9 +632,6 @@ video {
629
632
  .-left-1 {
630
633
  left: -0.25rem;
631
634
  }
632
- .top-2 {
633
- top: 0.5rem;
634
- }
635
635
  .right-2\.5 {
636
636
  right: 0.625rem;
637
637
  }
@@ -644,6 +644,12 @@ video {
644
644
  .bottom-2 {
645
645
  bottom: 0.5rem;
646
646
  }
647
+ .right-32 {
648
+ right: 8rem;
649
+ }
650
+ .left-32 {
651
+ left: 8rem;
652
+ }
647
653
  .top-auto {
648
654
  top: auto;
649
655
  }
@@ -771,6 +777,9 @@ video {
771
777
  .mt-12 {
772
778
  margin-top: 3rem;
773
779
  }
780
+ .mb-8 {
781
+ margin-bottom: 2rem;
782
+ }
774
783
  .mt-5 {
775
784
  margin-top: 1.25rem;
776
785
  }
@@ -1102,6 +1111,9 @@ video {
1102
1111
  .gap-1 {
1103
1112
  gap: 0.25rem;
1104
1113
  }
1114
+ .gap-9 {
1115
+ gap: 2.25rem;
1116
+ }
1105
1117
  .gap-x-3 {
1106
1118
  -moz-column-gap: 0.75rem;
1107
1119
  column-gap: 0.75rem;
@@ -1155,6 +1167,9 @@ video {
1155
1167
  .overflow-clip {
1156
1168
  overflow: clip;
1157
1169
  }
1170
+ .overflow-scroll {
1171
+ overflow: scroll;
1172
+ }
1158
1173
  .overflow-x-auto {
1159
1174
  overflow-x: auto;
1160
1175
  }
@@ -1167,6 +1182,9 @@ video {
1167
1182
  .overflow-y-clip {
1168
1183
  overflow-y: clip;
1169
1184
  }
1185
+ .scroll-auto {
1186
+ scroll-behavior: auto;
1187
+ }
1170
1188
  .truncate {
1171
1189
  overflow: hidden;
1172
1190
  text-overflow: ellipsis;
@@ -1221,6 +1239,10 @@ video {
1221
1239
  border-top-left-radius: 0px;
1222
1240
  border-bottom-left-radius: 0px;
1223
1241
  }
1242
+ .rounded-r-lg {
1243
+ border-top-right-radius: 0.5rem;
1244
+ border-bottom-right-radius: 0.5rem;
1245
+ }
1224
1246
  .rounded-tr-none {
1225
1247
  border-top-right-radius: 0px;
1226
1248
  }
@@ -1239,12 +1261,12 @@ video {
1239
1261
  .rounded-br-lg {
1240
1262
  border-bottom-right-radius: 0.5rem;
1241
1263
  }
1242
- .rounded-tl-none {
1243
- border-top-left-radius: 0px;
1244
- }
1245
1264
  .rounded-br-none {
1246
1265
  border-bottom-right-radius: 0px;
1247
1266
  }
1267
+ .rounded-tl-none {
1268
+ border-top-left-radius: 0px;
1269
+ }
1248
1270
  .border {
1249
1271
  border-width: 1px;
1250
1272
  }
@@ -1290,6 +1312,12 @@ video {
1290
1312
  .border-l-0 {
1291
1313
  border-left-width: 0px;
1292
1314
  }
1315
+ .border-l-2 {
1316
+ border-left-width: 2px;
1317
+ }
1318
+ .border-r-2 {
1319
+ border-right-width: 2px;
1320
+ }
1293
1321
  .border-dashed {
1294
1322
  border-style: dashed;
1295
1323
  }
@@ -1347,6 +1375,9 @@ video {
1347
1375
  --tw-border-opacity: 1;
1348
1376
  border-color: rgb(37 99 235 / var(--tw-border-opacity));
1349
1377
  }
1378
+ .border-buttonPrimary-default {
1379
+ border-color: var(--button-primary);
1380
+ }
1350
1381
  .border-t-white {
1351
1382
  --tw-border-opacity: 1;
1352
1383
  border-top-color: rgb(255 255 255 / var(--tw-border-opacity));
@@ -1439,6 +1470,10 @@ video {
1439
1470
  --tw-bg-opacity: 1;
1440
1471
  background-color: rgb(37 99 235 / var(--tw-bg-opacity));
1441
1472
  }
1473
+ .bg-yellow-400 {
1474
+ --tw-bg-opacity: 1;
1475
+ background-color: rgb(250 204 21 / var(--tw-bg-opacity));
1476
+ }
1442
1477
  .bg-primary-200 {
1443
1478
  --tw-bg-opacity: 1;
1444
1479
  background-color: rgb(196 222 253 / var(--tw-bg-opacity));
@@ -1451,10 +1486,6 @@ video {
1451
1486
  --tw-bg-opacity: 1;
1452
1487
  background-color: rgb(31 41 55 / var(--tw-bg-opacity));
1453
1488
  }
1454
- .bg-blue-700 {
1455
- --tw-bg-opacity: 1;
1456
- background-color: rgb(29 78 216 / var(--tw-bg-opacity));
1457
- }
1458
1489
  .bg-green-500 {
1459
1490
  --tw-bg-opacity: 1;
1460
1491
  background-color: rgb(34 197 94 / var(--tw-bg-opacity));
@@ -1836,6 +1867,9 @@ video {
1836
1867
  .duration-300 {
1837
1868
  transition-duration: 300ms;
1838
1869
  }
1870
+ .duration-700 {
1871
+ transition-duration: 700ms;
1872
+ }
1839
1873
  @import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;700&display=swap");
1840
1874
 
1841
1875
  body {
@@ -1916,10 +1950,6 @@ body {
1916
1950
  cursor: pointer;
1917
1951
  }
1918
1952
 
1919
- .hover\:overflow-auto:hover {
1920
- overflow: auto;
1921
- }
1922
-
1923
1953
  .hover\:bg-gray-200:hover {
1924
1954
  --tw-bg-opacity: 1;
1925
1955
  background-color: rgb(229 231 235 / var(--tw-bg-opacity));