@sikka/hawa 0.0.131 → 0.0.133

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.
@@ -7,10 +7,19 @@ type HawaAppLayoutTypes = {
7
7
  action: () => void;
8
8
  }[];
9
9
  currentPage: string;
10
+ pageTitle?: string;
10
11
  logoSymbol?: any;
11
12
  logoLink?: string;
12
13
  logoText?: any;
13
14
  children?: any;
15
+ topBar?: boolean;
16
+ profileMenuItems?: MenuItems[][];
17
+ };
18
+ type MenuItems = {
19
+ icon?: JSX.Element;
20
+ label: string;
21
+ action?: (e: React.MouseEvent<HTMLLIElement, MouseEvent>, item: string) => void;
22
+ isButton?: boolean;
14
23
  };
15
24
  export declare const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes>;
16
25
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.0.131",
3
+ "version": "0.0.133",
4
4
  "description": "UI Kit",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.es.js",
@@ -1,5 +1,5 @@
1
1
  import clsx from "clsx"
2
- import React, { ReactNode } from "react"
2
+ import React, { ReactNode, useEffect, useRef } from "react"
3
3
 
4
4
  interface TMenuTypes {
5
5
  menuItems: MenuItems[][]
@@ -13,6 +13,7 @@ interface TMenuTypes {
13
13
  anchor?: any
14
14
  children?: ReactNode
15
15
  buttonPosition?: "top-right" | "top-left" | "bottom-right" | "bottom-left"
16
+ onClickOutside?: any
16
17
  }
17
18
 
18
19
  type MenuItems = {
@@ -36,7 +37,22 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
36
37
  handleOpen,
37
38
  buttonPosition,
38
39
  children,
40
+ onClickOutside,
39
41
  }) => {
42
+ const ref = useRef(null)
43
+
44
+ useEffect(() => {
45
+ const handleClickOutside = (event) => {
46
+ if (ref.current && !ref.current.contains(event.target)) {
47
+ // onClickOutside && onClickOutside()
48
+ handleClose()
49
+ }
50
+ }
51
+ document.addEventListener("click", handleClickOutside, true)
52
+ return () => {
53
+ document.removeEventListener("click", handleClickOutside, true)
54
+ }
55
+ }, [onClickOutside])
40
56
  let defaultStyles =
41
57
  "border-none ring-offset-1 absolute z-10 w-44 divide-y divide-gray-100 overflow-y-clip rounded-lg bg-gray-50 shadow-lg transition-all dark:bg-gray-700"
42
58
  let positionStyles = {
@@ -60,6 +76,7 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
60
76
  {children}
61
77
 
62
78
  <div
79
+ ref={ref}
63
80
  className={clsx(
64
81
  defaultStyles,
65
82
  positionStyles[buttonPosition],
@@ -82,7 +99,7 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
82
99
  className={
83
100
  item.isButton
84
101
  ? "mx-1 flex cursor-pointer flex-row items-center rounded-lg bg-primary-500 py-2 px-4 text-white hover:bg-primary-600 rtl:flex-row-reverse dark:hover:bg-primary-600 dark:hover:text-white"
85
- : "mx-1 flex cursor-pointer flex-row items-center rounded-lg py-2 px-4 hover:bg-gray-100 rtl:flex-row-reverse dark:hover:bg-gray-600 dark:hover:text-white"
102
+ : "mx-1 flex cursor-pointer flex-row items-center rounded-lg py-2 px-4 hover:bg-gray-200 rtl:flex-row-reverse dark:hover:bg-gray-600 dark:hover:text-white"
86
103
  }
87
104
  >
88
105
  {withIcons && (
@@ -1,24 +1,77 @@
1
1
  import clsx from "clsx"
2
2
  import React, { useState } from "react"
3
+ import useDiscloser from "../hooks/useDiscloser"
4
+ import { HawaMenu } from "../elements"
3
5
 
4
6
  type HawaAppLayoutTypes = {
5
7
  drawerItems: { label: string; icon: any; slug: string; action: () => void }[]
6
8
  currentPage: string
9
+ pageTitle?: string
7
10
  logoSymbol?: any
8
11
  logoLink?: string
9
12
  logoText?: any
10
13
  children?: any
14
+ topBar?: boolean
15
+ profileMenuItems?: MenuItems[][]
16
+ }
17
+ type MenuItems = {
18
+ icon?: JSX.Element
19
+ label: string
20
+ action?: (
21
+ e: React.MouseEvent<HTMLLIElement, MouseEvent>,
22
+ item: string
23
+ ) => void
24
+ isButton?: boolean
11
25
  }
12
26
  export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = (
13
27
  props: any
14
28
  ) => {
15
29
  const [openSideMenu, setOpenSideMenu] = useState(false)
30
+ const { isOpen, onClose, onOpen } = useDiscloser(false)
31
+
16
32
  return (
17
33
  <>
34
+ {props.topBar && (
35
+ <div
36
+ className={clsx(
37
+ "fixed top-0 z-40 flex h-14 w-1/2 flex-row items-center justify-between bg-primary-400",
38
+ "w-[calc(100%-3rem)]",
39
+ "translate-x-[3rem]",
40
+ "p-2"
41
+ ,
42
+ 'pr-5'
43
+ )}
44
+ >
45
+ {props.pageTitle ? <div>{props.pageTitle}</div> : <div></div>}
46
+ {/* <div>currentPage</div> */}
47
+ <HawaMenu
48
+ buttonPosition="top-right"
49
+ menuItems={props.profileMenuItems}
50
+ handleClose={onClose}
51
+ handleOpen={onOpen}
52
+ open={isOpen}
53
+ >
54
+ <div className="relative cursor-pointer h-8 w-8 overflow-hidden rounded-full bg-gray-100 dark:bg-gray-600">
55
+ <svg
56
+ className="absolute -left-1 h-10 w-10 text-gray-400"
57
+ fill="currentColor"
58
+ viewBox="0 0 20 20"
59
+ xmlns="http://www.w3.org/2000/svg"
60
+ >
61
+ <path
62
+ fill-rule="evenodd"
63
+ d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z"
64
+ clip-rule="evenodd"
65
+ ></path>
66
+ </svg>
67
+ </div>
68
+ </HawaMenu>
69
+ </div>
70
+ )}
18
71
  <div
19
72
  onMouseEnter={() => setOpenSideMenu(true)}
20
73
  onMouseLeave={() => setOpenSideMenu(false)}
21
- className="fixed top-0 left-0 z-50 flex h-full w-12 flex-col bg-blue-300 transition-all hover:w-40"
74
+ className="fixed top-0 left-0 z-50 flex h-full w-12 flex-col bg-primary-400 transition-all hover:w-40"
22
75
  >
23
76
  <div className="flex flex-row p-2">
24
77
  {/* full logo */}
@@ -39,7 +92,7 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = (
39
92
  key={i}
40
93
  onClick={() => dItem.action(dItem.slug)}
41
94
  className={clsx(
42
- "m-1 flex cursor-pointer flex-row items-center overflow-x-clip rounded-lg p-2 pl-3 transition-all hover:bg-primary-400",
95
+ "m-1 flex cursor-pointer flex-row items-center overflow-x-clip rounded-lg p-2 pl-3 transition-all hover:bg-primary-500",
43
96
  props.currentPage === dItem.slug
44
97
  ? "bg-primary-600 text-white hover:bg-primary-600"
45
98
  : ""
@@ -63,7 +116,8 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = (
63
116
  "w-[calc(100%-3rem)]",
64
117
  "translate-x-[3rem]",
65
118
  "bg-red-900 text-white",
66
- "m-0"
119
+ "m-0",
120
+ props.topBar ? "mt-14" : ""
67
121
  )}
68
122
  >
69
123
  {props.children}
package/src/styles.css CHANGED
@@ -553,6 +553,9 @@ video {
553
553
  .top-5 {
554
554
  top: 1.25rem;
555
555
  }
556
+ .-left-1 {
557
+ left: -0.25rem;
558
+ }
556
559
  .top-auto {
557
560
  top: auto;
558
561
  }
@@ -565,9 +568,6 @@ video {
565
568
  .top-2 {
566
569
  top: 0.5rem;
567
570
  }
568
- .-left-1 {
569
- left: -0.25rem;
570
- }
571
571
  .z-10 {
572
572
  z-index: 10;
573
573
  }
@@ -673,6 +673,9 @@ video {
673
673
  .mr-4 {
674
674
  margin-right: 1rem;
675
675
  }
676
+ .mt-14 {
677
+ margin-top: 3.5rem;
678
+ }
676
679
  .mt-5 {
677
680
  margin-top: 1.25rem;
678
681
  }
@@ -835,12 +838,12 @@ video {
835
838
  .w-2\/3 {
836
839
  width: 66.666667%;
837
840
  }
838
- .w-12 {
839
- width: 3rem;
840
- }
841
841
  .w-\[calc\(100\%-3rem\)\] {
842
842
  width: calc(100% - 3rem);
843
843
  }
844
+ .w-12 {
845
+ width: 3rem;
846
+ }
844
847
  .w-\[calc\(100\%-1rem\)\] {
845
848
  width: calc(100% - 1rem);
846
849
  }
@@ -1488,6 +1491,9 @@ video {
1488
1491
  .pl-10 {
1489
1492
  padding-left: 2.5rem;
1490
1493
  }
1494
+ .pr-5 {
1495
+ padding-right: 1.25rem;
1496
+ }
1491
1497
  .pl-3 {
1492
1498
  padding-left: 0.75rem;
1493
1499
  }
@@ -1853,9 +1859,9 @@ body {
1853
1859
  --tw-bg-opacity: 1;
1854
1860
  background-color: rgb(55 65 81 / var(--tw-bg-opacity));
1855
1861
  }
1856
- .hover\:bg-primary-400:hover {
1862
+ .hover\:bg-primary-500:hover {
1857
1863
  --tw-bg-opacity: 1;
1858
- background-color: rgb(116 177 251 / var(--tw-bg-opacity));
1864
+ background-color: rgb(61 147 249 / var(--tw-bg-opacity));
1859
1865
  }
1860
1866
  .hover\:text-gray-900:hover {
1861
1867
  --tw-text-opacity: 1;