'use client'; import { Dialog, Disclosure, Popover, Transition } from '@headlessui/react'; import { Bars4Icon, ChevronDownIcon, XMarkIcon, } from '@heroicons/react/24/outline'; import cx from 'classnames'; import Link from 'next/link'; import { Fragment, ReactElement, useEffect, useState } from 'react'; import { ButtonLink, ButtonLinkProps } from '../button'; import { resourceMenuItems } from './menu-items'; import { MobileMenuItem } from './mobile-menu-item'; import { SectionsMenu } from './sections-menu'; import { AlgoliaSearch } from '@nx/nx-dev/feature-search'; import { GitHubIcon, NxIcon } from '@nx/nx-dev/ui-icons'; interface HeaderProps { ctaButtons?: ButtonLinkProps[]; } export function Header({ ctaButtons }: HeaderProps): ReactElement { let [isOpen, setIsOpen] = useState(false); // We need to close the popover if the route changes or the window is resized to prevent the popover from being stuck open. const checkSizeAndClosePopover = () => { const breakpoint = 1024; // This is the standard Tailwind lg breakpoint value if (window.innerWidth < breakpoint) { setIsOpen(false); } }; useEffect(() => { window.addEventListener('resize', checkSizeAndClosePopover); return () => { window.removeEventListener('resize', checkSizeAndClosePopover); }; }, []); const defaultCtaButtons: ButtonLinkProps[] = [ { href: 'https://cloud.nx.app/get-started?utm_source=nx-dev&utm_medium=header&utm_campaign=try-nx-cloud', variant: 'primary', size: 'small', target: '_blank', title: 'Try Nx Cloud for free', children: Try Nx Cloud for free, }, ]; const buttonsToRender = ctaButtons || defaultCtaButtons; return (
{/*DESKTOP*/}
{/*PRIMARY NAVIGATION*/}
{/*LOGO*/} Nx
{/*SECONDARY NAVIGATION*/}
{/*MOBILE*/}
{/*LOGO*/} Nx
setIsOpen(!isOpen)} >
Nx Nx
Try Nx Cloud for free
Docs Blog {/*Resources*/} {({ open }) => ( <> Resources {Object.values(resourceMenuItems) .flat() .map((item) => ( ))} )} Nx Cloud Pricing Powerpack Enterprise Contact
); }