UNPKG

@sikka/hawa

Version:

Modern UI Kit made with Tailwind

132 lines (128 loc) 4.8 kB
"use client"; // layout/navbar/Navbar.tsx import React, { useState } from "react"; // util/index.ts import { clsx } from "clsx"; import { twMerge } from "tailwind-merge"; function cn(...inputs) { return twMerge(clsx(inputs)); } // elements/collapsible/Collapsible.tsx import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"; var Collapsible = CollapsiblePrimitive.Root; var CollapsibleTrigger2 = CollapsiblePrimitive.CollapsibleTrigger; var CollapsibleContent2 = CollapsiblePrimitive.CollapsibleContent; // layout/navbar/Navbar.tsx var Navbar = ({ backgroundColor, logo, handleLogoClick, ...props }) => { var _a, _b; const [isOpen, setIsOpen] = useState(false); return /* @__PURE__ */ React.createElement("nav", { className: "hawa-sticky hawa-top-2 hawa-transition-all" }, /* @__PURE__ */ React.createElement( Collapsible, { className: "hawa-relative hawa-m-2 hawa-rounded hawa-p-2", style: { backgroundColor: backgroundColor || "#1f2937" } }, /* @__PURE__ */ React.createElement("div", { className: "hawa-flex hawa-items-center hawa-justify-between hawa-px-3" }, /* @__PURE__ */ React.createElement("div", { className: "hawa-flex hawa-items-center" }, /* @__PURE__ */ React.createElement( "div", { className: "hawa-p-1.5 hawa-text-xl hawa-font-bold hawa-text-white", onClick: () => { if (handleLogoClick) { handleLogoClick(); } } }, logo )), /* @__PURE__ */ React.createElement("div", { className: "hawa-hidden md:hawa-flex" }, (_a = props.menuItems) == null ? void 0 : _a.map((item, i) => /* @__PURE__ */ React.createElement( "div", { key: i, onClick: item.action, className: "hawa-cursor-pointer hawa-rounded hawa-p-1.5 hawa-px-2 hawa-text-center hawa-text-sm hawa-text-white hawa-transition-all hover:hawa-bg-gray-300 hover:hawa-text-black" }, item.label ))), /* @__PURE__ */ React.createElement("div", { className: "hawa-m-0 hawa-flex hawa-h-fit hawa-p-0 md:hawa-hidden" }, /* @__PURE__ */ React.createElement( CollapsibleTrigger2, { onClick: () => setIsOpen(!isOpen), className: "hawa-h-full hawa-text-white selection:hawa-p-0", "aria-label": "Toggle menu" }, /* @__PURE__ */ React.createElement( "svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: cn( "hawa-fixed hawa-h-6 hawa-w-6", isOpen ? "hawa-invisible" : "hawa-visible" ) }, /* @__PURE__ */ React.createElement("line", { x1: "4", x2: "20", y1: "12", y2: "12" }), /* @__PURE__ */ React.createElement("line", { x1: "4", x2: "20", y1: "6", y2: "6" }), /* @__PURE__ */ React.createElement("line", { x1: "4", x2: "20", y1: "18", y2: "18" }) ), /* @__PURE__ */ React.createElement( "svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: cn( "hawa-h-6 hawa-w-6", !isOpen ? "hawa-invisible" : "hawa-visible" ) }, /* @__PURE__ */ React.createElement("path", { d: "M18 6 6 18" }), /* @__PURE__ */ React.createElement("path", { d: "m6 6 12 12" }) ) ))), /* @__PURE__ */ React.createElement( CollapsibleContent2, { className: cn( "data-[state=closed]:hawa-opacity-0", "data-[state=open]:hawa-animate-in", "data-[state=open]:hawa-fade-in-90", "hawa-absolute hawa-left-0 hawa-top-[60px] hawa-flex hawa-flex-col hawa-rounded hawa-border hawa-bg-gray-200 hawa-p-1 hawa-transition-all" // "hawa-transition-all hawa-bg-gray-400 hawa-fixed hawa-left-0 hawa-top-[72px] hawa-w-full hawa-flex hawa-flex-col" ), style: { width: "calc(100%)", zIndex: -100 } }, (_b = props.menuItems) == null ? void 0 : _b.map((item, i) => /* @__PURE__ */ React.createElement( "div", { key: i, onClick: item.action, className: "hawa-cursor-pointer hawa-rounded hawa-p-2 hawa-px-10 hawa-text-center hawa-text-black hawa-transition-all hover:hawa-bg-gray-300" }, item.label )) ) )); }; export { Navbar }; //# sourceMappingURL=index.mjs.map