chore: show menu item only if section anchor provided

This commit is contained in:
Zotov Ivan Yuryevich
2026-06-17 22:46:41 +03:00
parent 5c7f09e37a
commit af201556c2
7 changed files with 152 additions and 51 deletions

View File

@@ -2,6 +2,7 @@ import { Menu, X, ChevronDown } from 'lucide-react'
import { useState } from 'react'
import { ContactModal } from '../components/ContactModal'
import type { MenuItemsQuery } from '../graphql/graphql'
import type { HomeSectionAnchors } from '../lib/cms/sections/homeNav'
import type { SiteConfigContact } from '../lib/cms/contact/types'
import { navigateHomeSectionAnchor } from '../lib/scrollToHash'
@@ -12,9 +13,16 @@ export interface HeaderProps {
contacts?: readonly SiteConfigContact[]
solutions?: readonly CategoryNavItem[]
services?: readonly CategoryNavItem[]
sectionAnchors?: HomeSectionAnchors
}
export function Header({ siteTitle = '', contacts = [], solutions = [], services = [] }: HeaderProps) {
export function Header({
siteTitle = '',
contacts = [],
solutions = [],
services = [],
sectionAnchors = {},
}: HeaderProps) {
const [isMenuOpen, setIsMenuOpen] = useState(false)
const [isSolutionsOpen, setIsSolutionsOpen] = useState(false)
const [isServicesOpen, setIsServicesOpen] = useState(false)
@@ -86,20 +94,24 @@ export function Header({ siteTitle = '', contacts = [], solutions = [], services
)}
</div>
)}
<a
href="/#cases"
className="text-gray-700 hover:text-blue-600 transition-colors whitespace-nowrap"
onClick={e => navigateHomeSectionAnchor(e, 'cases')}
>
Кейсы
</a>
<a
href="/#about"
className="text-gray-700 hover:text-blue-600 transition-colors whitespace-nowrap"
onClick={e => navigateHomeSectionAnchor(e, 'about')}
>
О компании
</a>
{sectionAnchors.cases && (
<a
href={`/#${sectionAnchors.cases}`}
className="text-gray-700 hover:text-blue-600 transition-colors whitespace-nowrap"
onClick={e => navigateHomeSectionAnchor(e, sectionAnchors.cases!)}
>
Кейсы
</a>
)}
{sectionAnchors.about && (
<a
href={`/#${sectionAnchors.about}`}
className="text-gray-700 hover:text-blue-600 transition-colors whitespace-nowrap"
onClick={e => navigateHomeSectionAnchor(e, sectionAnchors.about!)}
>
О компании
</a>
)}
<a
href="/#contact"
className="text-gray-700 hover:text-blue-600 transition-colors whitespace-nowrap"
@@ -185,26 +197,30 @@ export function Header({ siteTitle = '', contacts = [], solutions = [], services
)}
</div>
)}
<a
href="/#cases"
onClick={e => {
navigateHomeSectionAnchor(e, 'cases')
setIsMenuOpen(false)
}}
className="text-gray-700 hover:text-blue-600"
>
Кейсы
</a>
<a
href="/#about"
onClick={e => {
navigateHomeSectionAnchor(e, 'about')
setIsMenuOpen(false)
}}
className="text-gray-700 hover:text-blue-600"
>
О компании
</a>
{sectionAnchors.cases && (
<a
href={`/#${sectionAnchors.cases}`}
onClick={e => {
navigateHomeSectionAnchor(e, sectionAnchors.cases!)
setIsMenuOpen(false)
}}
className="text-gray-700 hover:text-blue-600"
>
Кейсы
</a>
)}
{sectionAnchors.about && (
<a
href={`/#${sectionAnchors.about}`}
onClick={e => {
navigateHomeSectionAnchor(e, sectionAnchors.about!)
setIsMenuOpen(false)
}}
className="text-gray-700 hover:text-blue-600"
>
О компании
</a>
)}
<a
href="/#contact"
onClick={e => {