@instincthub/react-ui 0.1.0 → 0.1.1
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/dist/src/assets/css/navbar/responsive-navbar.css +1 -0
- package/dist/src/components/navbar/ResponsiveNavbar.js +1 -1
- package/dist/src/types/components/navbar/ResponsiveNavbar.d.ts +27 -1
- package/dist/src/types/types/index.d.ts +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{
|
|
1
|
+
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as n,jsx as i,Fragment as r}from"react/jsx-runtime";import{useState as a,useEffect as t}from"react";import o from"next/link";import l from"next/image";import u from"@mui/icons-material/LightMode";import c from"@mui/icons-material/DarkMode";var s=function(s){var h,d,m=s.session,b=s.logoSrc,v=s.logoAlt,p=void 0===v?"Company Logo":v,f=s.navLinks,g=s.userAreaLinks,N=void 0===g?[]:g,w=s.theme,k=void 0===w?"LightMode":w,L=s.containerClass,E=void 0===L?"ihub-container":L,M=s.topBanner,x=s.bottomBanner,_=s.hideTopBanner,D=void 0!==_&&_,B=s.hideBottomBanner,C=void 0!==B&&B,S=a(!1),A=e(S,2),y=A[0],j=A[1],z=a(!1),I=e(z,2),P=I[0],T=I[1],U=a(!1),H=e(U,2),W=H[0],Y=H[1],q=a(null),F=e(q,2),G=F[0],J=F[1],K=a(null),O=e(K,2),Q=O[0],R=O[1],V=a(k),X=e(V,2),Z=X[0],$=X[1],ee=null==m||null===(h=m.user)||void 0===h?void 0:h.name;t((function(){var e=function(){window.scrollY>50?T(!0):T(!1)};return window.addEventListener("scroll",e),function(){return window.removeEventListener("scroll",e)}}),[]),t((function(){var e=localStorage.getItem("theme");e&&($(e),document.documentElement.classList.remove("LightMode","DarkMode"),document.documentElement.classList.add(e))}),[]),t((function(){var e=function(e){var n=e.target;!y||n.closest(".ihub-navbar-elements")||n.closest(".ihub-hamburger")||j(!1),W&&!n.closest(".ihub-user-dropdown")&&(Y(!1),R(null)),null===G||n.closest(".ihub-nav-submenu-".concat(G))||J(null)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}),[y,W,G,Q]),t((function(){var e=function(){window.innerWidth>768&&y&&j(!1)};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[y]);return n("header",{className:"ihub-navbar ".concat(P?"ihub-navbar-scrolled":""," ").concat("DarkMode"===Z?"ihub-navbar-dark":""),children:[M&&!D&&i("div",{className:"ihub-navbar-top-banner",children:M}),i("div",{className:E,children:n("nav",{className:"ihub-navbar-container",children:[i("div",{className:"ihub-navbar-logo",children:i(o,{href:"/",children:i(l,{src:b,alt:p,width:120,height:40,className:"ihub-logo-image"})})}),n("div",{className:"ihub-hamburger",onClick:function(){j(!y),J(null)},children:[i("div",{className:"ihub-hamburger-line ".concat(y?"ihub-active":"")}),i("div",{className:"ihub-hamburger-line ".concat(y?"ihub-active":"")}),i("div",{className:"ihub-hamburger-line ".concat(y?"ihub-active":"")})]}),n("div",{className:"ihub-navbar-elements ".concat(y?"ihub-active":""),children:[n("ul",{className:"ihub-nav-links",children:[f.map((function(e,a){return i("li",{className:"ihub-nav-item ihub-nav-submenu-".concat(a," ").concat(e.submenu?"ihub-has-submenu":""," ").concat(G===a?"ihub-submenu-active":""),children:e.submenu?n(r,{children:[n("a",{href:"#",onClick:function(e){return function(e,n){n.preventDefault(),J(G===e?null:e)}(a,e)},className:"ihub-submenu-toggle ".concat(e.highlight?"ihub-nav-highlight":""),children:[e.title,i("span",{className:"ihub-dropdown-arrow"})]}),G===a&&i("ul",{className:"ihub-submenu",children:e.submenu.map((function(e,r){return i("li",{className:"ihub-submenu-item",children:e.isExternal?n("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",children:[e.icon&&i("span",{className:"ihub-submenu-icon",children:e.icon}),e.title]}):n(o,{href:e.href,children:[e.icon&&i("span",{className:"ihub-submenu-icon",children:e.icon}),e.title]})},r)}))})]}):i(r,{children:e.isExternal?i("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",className:e.highlight?"ihub-nav-highlight":"",children:e.title}):i(o,{href:e.href,className:e.highlight?"ihub-nav-highlight":"",children:e.title})})},a)})),i("li",{className:"ihub-nav-item",children:i("button",{onClick:function(){var e="LightMode"===Z?"DarkMode":"LightMode";document.documentElement.classList.remove("LightMode","DarkMode"),document.documentElement.classList.add(e),$(e),localStorage.setItem("theme",e)},className:"ihub-theme-toggle","aria-label":"Switch to ".concat("LightMode"===Z?"DarkMode":"LightMode"," mode"),children:i("LightMode"===Z?c:u,{})})})]}),i("div",{className:"ihub-navbar-user-area",children:m?n("div",{className:"ihub-user-dropdown",children:[n("div",{className:"ihub-user-profile",onClick:function(){Y(!W),R(null)},children:[null!=ee&&ee.picture?i(l,{src:ee.picture,alt:"User",width:40,height:40,className:"ihub-user-avatar"}):i("div",{className:"ihub-user-initials",children:(null==ee||null===(d=ee.full_name)||void 0===d?void 0:d.charAt(0))||"U"}),n("span",{className:"ihub-user-name ihub-hide-sm",children:[null==ee?void 0:ee.full_name,i("span",{className:"ihub-dropdown-arrow"})]})]}),W&&n("div",{className:"ihub-dropdown ihub-user-menu-dropdown",children:[N.map((function(e,r){return i("div",{className:"ihub-dropdown-item-wrapper",children:e.submenu?n("div",{className:"ihub-dropdown-with-submenu",children:[n("a",{href:"#",className:"ihub-dropdown-item ihub-dropdown-parent",onClick:function(e){return function(e,n){n.preventDefault(),n.stopPropagation(),R(Q===e?null:e)}(r,e)},target:e.isExternal?"_blank":void 0,rel:e.isExternal?"noopener noreferrer":void 0,children:[e.icon&&i("span",{className:"ihub-dropdown-icon",children:e.icon}),e.title,i("span",{className:"ihub-submenu-caret ".concat(Q===r?"ihub-active":"")})]}),Q===r&&i("div",{className:"ihub-user-submenu",children:e.submenu.map((function(e,r){return n(o,{href:e.href,className:"ihub-dropdown-subitem",target:e.isExternal?"_blank":void 0,rel:e.isExternal?"noopener noreferrer":void 0,children:[e.icon&&i("span",{className:"ihub-dropdown-icon",children:e.icon}),e.title]},r)}))})]}):n(o,{href:e.href,className:"ihub-dropdown-item",children:[e.icon&&i("span",{className:"ihub-dropdown-icon",children:e.icon}),e.title]})},r)})),n(o,{href:"/api/auth/signout",className:"ihub-dropdown-item ihub-signout",children:[i("span",{className:"ihub-dropdown-icon",children:"⤴"}),"Sign out"]})]})]}):i("div",{className:"ihub-auth-buttons",children:N.map((function(e,n){return e.isButton?i(o,{href:e.href,className:"".concat("outline"===e.buttonStyle?"ihub-outlined-btn":"ihub-important-btn"),target:e.isExternal?"_blank":void 0,rel:e.isExternal?"noopener noreferrer":void 0,children:e.title},n):i(o,{href:e.href,className:"ihub-auth-link",children:e.title},n)}))})})]})]})}),x&&!C&&i("div",{className:"ihub-navbar-bottom-banner",children:x})]})};export{s as default};
|
|
2
2
|
//# sourceMappingURL=ResponsiveNavbar.js.map
|
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
import { NavbarPropsType } from "../../types";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @example
|
|
4
|
+
* ```tsx
|
|
5
|
+
* <ResponsiveNavbar
|
|
6
|
+
* session={session}
|
|
7
|
+
* logoSrc="https://example.com/logo.png"
|
|
8
|
+
* logoAlt="Company Logo"
|
|
9
|
+
* navLinks={navLinks}
|
|
10
|
+
* userAreaLinks={userAreaLinks}
|
|
11
|
+
* theme="LightMode"
|
|
12
|
+
* containerClass="ihub-container"
|
|
13
|
+
* topBanner={<div>Top Banner</div>}
|
|
14
|
+
* />
|
|
15
|
+
* ```
|
|
16
|
+
* @param {SessionType} session - The session object
|
|
17
|
+
* @param {string} logoSrc - The source of the logo
|
|
18
|
+
* @param {string} logoAlt - The alt text of the logo
|
|
19
|
+
* @param {NavLinkType[]} navLinks - The navigation links
|
|
20
|
+
* @param {UserAreaLinkType[]} userAreaLinks - The user area links
|
|
21
|
+
* @param {string} theme - The theme of the navbar
|
|
22
|
+
* @param {string} containerClass - The class of the container
|
|
23
|
+
* @param {React.ReactNode | JSX.Element | null} topBanner - The top banner
|
|
24
|
+
* @param {React.ReactNode | JSX.Element | null} bottomBanner - The bottom banner
|
|
25
|
+
* @param {boolean} hideTopBanner - Whether to hide the top banner
|
|
26
|
+
* @param {boolean} hideBottomBanner - Whether to hide the bottom banner
|
|
27
|
+
* */
|
|
28
|
+
declare const ResponsiveNavbar: ({ session, logoSrc, logoAlt, navLinks, userAreaLinks, theme: initialTheme, containerClass, topBanner, bottomBanner, hideTopBanner, hideBottomBanner, }: NavbarPropsType) => import("react/jsx-runtime").JSX.Element;
|
|
3
29
|
export default ResponsiveNavbar;
|
|
@@ -240,6 +240,10 @@ export interface NavbarPropsType {
|
|
|
240
240
|
userAreaLinks?: UserAreaLinkType[];
|
|
241
241
|
theme?: "LightMode" | "DarkMode";
|
|
242
242
|
containerClass?: string;
|
|
243
|
+
topBanner?: React.ReactNode | JSX.Element | null;
|
|
244
|
+
hideTopBanner?: boolean;
|
|
245
|
+
bottomBanner?: React.ReactNode | JSX.Element | null;
|
|
246
|
+
hideBottomBanner?: boolean;
|
|
243
247
|
}
|
|
244
248
|
export interface LoginFormPropsType {
|
|
245
249
|
params?: SearchParamsType;
|