import { Disclosure } from '@headlessui/react'; import { Bars3Icon, XMarkIcon } from '@heroicons/react/24/solid'; import React from 'react'; import shield from '../../assets/cu-shield.svg'; import { UserInfoType } from '../../types/UserInfo'; import { Avatar } from '../Avatar'; import { DropDown, DropDownItemProps } from '../DropDown'; import { Link } from '../Link/Link'; import { Search } from '../Search'; export interface LinkProps { title: string; link: string; active: boolean; } export interface mobileLoginProps { title: string; link?: string; onClick?: (event: React.MouseEvent) => void; } export interface TopNavProps { title: string; logoUrl?: string; brand?: string; login?: React.ReactNode; hasSearch?: boolean; sourceData?: any; children?: React.ReactNode; sticky?: boolean; navLinks?: LinkProps[]; mobileLinks?: LinkProps[]; userMenuItems?: any; userInfo?: UserInfoType; searchOn?: string; mobileLogin?: mobileLoginProps; } export const TopNav = ({ children, logoUrl, title, brand, hasSearch, sourceData, searchOn, navLinks, mobileLinks, userMenuItems, userInfo, sticky, login, mobileLogin, }: TopNavProps) => { const brandLogo = brand ? (

{title}

{title}
) : (
Carleton Shield

{title}

); return ( {({ open }) => ( <>
{/* Logo */}
{brandLogo}
{/* mobile Menu open Button */}
{hasSearch && sourceData && (
)} main menu {open ? (
{/* navigation Links */}
    {navLinks && navLinks.map((item, index) => (
  • {item.title}
  • ))}
{/* Login , search and Other Childrens */}
{/* search */} {/* this will just search on title in database , we need to extend it to add other props search on to top nav */} {hasSearch && sourceData && (
)} {children} {/* Login */} {!userInfo && login} {userInfo && !userMenuItems && ( )} {userInfo && userMenuItems && ( )}
{/* Mobile Menu */} {/* active state on mobile */} {({ close }) => ( <>
{mobileLinks && mobileLinks.map((item, index) => ( close()}>{item.title} ))} {/* login button */} {!userInfo && mobileLogin && ( <> {/* mobileLogin */} { mobileLogin.onClick && e.preventDefault(); mobileLogin.onClick && mobileLogin.onClick(e); close(); }} > {mobileLogin.title} )}
{/* userInfo */} {userInfo && (
{userInfo.firstName + ' ' + userInfo.lastName}
{userMenuItems && userMenuItems.map( (item: DropDownItemProps, index: any) => ( { item.onClick && e.preventDefault(); item.onClick && item.onClick(e); close(); }} > {item.title} ) )}
)} )}
)}
); };