@sikka/hawa 0.0.138 → 0.0.139

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.138",
3
+ "version": "0.0.139",
4
4
  "description": "UI Kit",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.es.js",
@@ -11,11 +11,11 @@ type StatTypes = {
11
11
  handleClick?: () => void
12
12
  }
13
13
  export const HawaStats: React.FunctionComponent<StatTypes> = (props) => {
14
- let defaultStyle = "flex flex-col gap-1 rounded-lg p-4 text-sm h-fit max-h-fit"
14
+ let defaultStyle =
15
+ "flex flex-col gap-1 rounded-lg p-4 text-sm h-fit max-h-fit"
15
16
  let statStyles = {
16
17
  plain: "",
17
18
  contained: "bg-primary-200 w-fit",
18
- // outlined: "border-2 border-primary-200 w-fit",
19
19
  outlined: "ring-2 w-fit",
20
20
  }
21
21
  return (
@@ -29,7 +29,7 @@ export const HawaStats: React.FunctionComponent<StatTypes> = (props) => {
29
29
  ) : (
30
30
  <div className="text-2xl font-bold">{props.number}</div>
31
31
  )}{" "}
32
- <div className="text-xs">{props.helperText}</div>
32
+ {props.helperText && <div className="text-xs">{props.helperText}</div>}{" "}
33
33
  </div>
34
34
  )
35
35
  }
@@ -1,7 +1,7 @@
1
1
  import { useState, useEffect } from "react"
2
2
 
3
3
  const useBreakpoint = () => {
4
- const [breakpoint, setBreakpoint] = useState(1200)
4
+ const [breakpoint, setBreakpoint] = useState(window.innerWidth)
5
5
  const resize = () => {
6
6
  setBreakpoint(window.innerWidth)
7
7
  }
@@ -1,8 +1,9 @@
1
1
  import clsx from "clsx"
2
- import React, { useState } from "react"
2
+ import React, { useEffect, useRef, useState } from "react"
3
3
  import useDiscloser from "../hooks/useDiscloser"
4
4
  import { HawaMenu } from "../elements"
5
-
5
+ import { HiMenu } from "react-icons/hi"
6
+ import useBreakpoint from "../hooks/useBreakpoint"
6
7
  type HawaAppLayoutTypes = {
7
8
  drawerItems: { label: string; icon: any; slug: string; action: () => void }[]
8
9
  currentPage: string
@@ -28,19 +29,42 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = (
28
29
  ) => {
29
30
  const [openSideMenu, setOpenSideMenu] = useState(false)
30
31
  const { isOpen, onClose, onOpen } = useDiscloser(false)
32
+ const ref = useRef(null)
33
+
34
+ const size = useBreakpoint()
35
+ console.log("size is ", size)
36
+ useEffect(() => {
37
+ const handleClickOutside = (event) => {
38
+ if (ref.current && !ref.current.contains(event.target)) {
39
+ // onClickOutside && onClickOutside()
40
+ setOpenSideMenu(false)
41
+ }
42
+ }
43
+ document.addEventListener("click", handleClickOutside, true)
44
+ return () => {
45
+ document.removeEventListener("click", handleClickOutside, true)
46
+ }
47
+ }, [])
31
48
 
32
49
  return (
33
50
  <>
34
51
  {props.topBar && (
35
52
  <div
36
53
  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]",
54
+ "fixed top-0 z-40 flex h-14 flex-row items-center justify-between bg-primary-400",
55
+ size > 600 ? "w-[calc(100%-3rem)] translate-x-[3rem]" : "w-full",
40
56
  "p-2",
41
57
  "pr-5"
42
58
  )}
43
59
  >
60
+ {size > 600 ? null : (
61
+ <div
62
+ onClick={() => setOpenSideMenu(true)}
63
+ className=" cursor-pointer rounded-lg p-2 transition-all hover:bg-gray-100"
64
+ >
65
+ <HiMenu size={30} />
66
+ </div>
67
+ )}
44
68
  {props.pageTitle ? <div>{props.pageTitle}</div> : <div></div>}
45
69
  <HawaMenu
46
70
  buttonPosition="top-right"
@@ -69,10 +93,14 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = (
69
93
  <div
70
94
  onMouseEnter={() => setOpenSideMenu(true)}
71
95
  onMouseLeave={() => setOpenSideMenu(false)}
72
- className="fixed top-0 left-0 z-50 flex h-full w-12 flex-col overflow-auto bg-primary-400 transition-all hover:w-40"
96
+ ref={ref}
97
+ className={clsx(
98
+ "fixed top-0 left-0 z-50 flex h-full flex-col overflow-auto bg-primary-400 transition-all hover:w-40",
99
+ size > 600 ? "w-12" : "w-0",
100
+ openSideMenu ? "w-40" : ""
101
+ )}
73
102
  >
74
- <div className="flex flex-row p-2">
75
- {/* full logo */}
103
+ <div className="flex flex-row items-center justify-center bg-red-300 p-2">
76
104
  {openSideMenu ? (
77
105
  <img
78
106
  className={clsx("h-10", !openSideMenu ? "invisible" : "visible")}
@@ -85,6 +113,7 @@ export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = (
85
113
  />
86
114
  )}
87
115
  </div>
116
+
88
117
  {props.drawerItems.map((dSection, j) => (
89
118
  <div className="flex flex-col items-stretch justify-center">
90
119
  {dSection.map((dItem, i) => {
package/src/styles.css CHANGED
@@ -850,6 +850,9 @@ video {
850
850
  .w-12 {
851
851
  width: 3rem;
852
852
  }
853
+ .w-40 {
854
+ width: 10rem;
855
+ }
853
856
  .w-10\/12 {
854
857
  width: 83.333333%;
855
858
  }
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_sikka_hawa=self.webpackChunk_sikka_hawa||[]).push([[745],{"./node_modules/react-dom/client.js":(__unused_webpack_module,exports,__webpack_require__)=>{var m=__webpack_require__("./node_modules/react-dom/index.js");exports.createRoot=m.createRoot,exports.hydrateRoot=m.hydrateRoot}}]);