import { useState } from 'react' import cx from 'classnames' import { useRouter } from 'next/router' import { MarkGithubIcon, ThreeBarsIcon, XIcon } from '@primer/octicons-react' import { ButtonOutline } from '@primer/components' import { Link } from 'components/Link' import { useMainContext } from 'components/context/MainContext' import { LanguagePicker } from './LanguagePicker' import { HeaderNotifications } from 'components/page-header/HeaderNotifications' import { ProductPicker } from 'components/page-header/ProductPicker' import { useTranslation } from 'components/hooks/useTranslation' import { HomepageVersionPicker } from 'components/landing/HomepageVersionPicker' import { Search } from 'components/Search' export const Header = () => { const router = useRouter() const { relativePath, currentLayoutName, error } = useMainContext() const { t } = useTranslation(['header', 'homepage']) const [isMenuOpen, setIsMenuOpen] = useState(false) // the graphiql explorer utilizes `?query=` in the url and we don't want our search bar to mess that up const updateSearchParams = router.asPath !== 'graphql/overview/explorer' const showVersionPicker = relativePath === 'index.md' || currentLayoutName === 'product-landing' || currentLayoutName === 'product-sublanding' || currentLayoutName === 'release-notes' return (
{error !== '404' && }
{/* desktop header */}
{showVersionPicker && (
)}
{/* */} {relativePath !== 'index.md' && error !== '404' && (
)}
{/* mobile header */}
setIsMenuOpen(!isMenuOpen)} aria-label="Navigation Menu" > {isMenuOpen ? : }
{/* mobile menu contents */}

{t('explore_by_product')}

{/* */} {showVersionPicker && (
)} {/* */}
{/* */} {relativePath !== 'index.md' && error !== '404' && (
)}
) }