Files
mip-website/pages/components/Layout/header.js
T
2026-10-07 17:56:50 +03:30

403 lines
12 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React, { useState } from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { FiChevronDown, FiInstagram, FiMapPin, FiMenu, FiPhone, FiX } from 'react-icons/fi'
const mainLinks = [
{ href: '/', label: 'صفحه اصلی' },
{ href: '/landing', label: 'معرفی بیمارستان' },
{ href: '/components/service', label: 'بخش‌های درمانی' },
{ href: '/Gallery', label: 'گالری' },
{ href: '/recruitment', label: 'استخدام و همکاری' },
]
const moreLinks = [
{ href: '/page/about', label: 'درباره ما' },
{ href: '/page/Directors', label: 'تیم پروژه' },
]
export default function Header() {
const [menuOpen, setMenuOpen] = useState(false)
const { pathname } = useRouter()
const closeMenu = () => setMenuOpen(false)
const moreIsActive = moreLinks.some(({ href }) => pathname === href)
return (
<header className='site-header' dir='rtl' onKeyDown={event => event.key === 'Escape' && closeMenu()}>
<div className='topbar'>
<div className='header-container topbar-inner'>
<div className='topbar-location'>
<FiMapPin aria-hidden='true' />
<span>تهران، شهر جدید پرند، بلوار شهید قاسم سلیمانی، انتهای فاز ۵</span>
</div>
<div className='topbar-actions'>
<a href='tel:02153457000' className='phone-link'>
<FiPhone aria-hidden='true' />
<span dir='ltr'>۰۲۱-۵۳۴۵۷۰۰۰</span>
</a>
<span className='topbar-divider' aria-hidden='true' />
<a
className='social-link'
href='https://www.instagram.com/miphospital/'
target='_blank'
rel='noopener noreferrer'
aria-label='اینستاگرام بیمارستان مهر پرند'
>
<FiInstagram aria-hidden='true' />
</a>
</div>
</div>
</div>
<div className='mainbar'>
<div className='header-container mainbar-inner'>
<Link href='/'>
<a className='brand' onClick={closeMenu} aria-label='بیمارستان مهر پرند، صفحه اصلی'>
<img src='/resource/logo/logo-green.png' alt='' width='56' height='53' />
<span className='brand-copy'>
<strong>بیمارستان مهر پرند</strong>
<small>همراه سلامت شما</small>
</span>
</a>
</Link>
<button
className='menu-toggle'
type='button'
aria-label={menuOpen ? 'بستن منو' : 'باز کردن منو'}
aria-expanded={menuOpen}
aria-controls='site-navigation'
onClick={() => setMenuOpen(open => !open)}
>
{menuOpen ? <FiX aria-hidden='true' /> : <FiMenu aria-hidden='true' />}
</button>
<nav id='site-navigation' className={`navigation ${menuOpen ? 'is-open' : ''}`} aria-label='منوی اصلی'>
<div className='nav-links'>
{mainLinks.map(({ href, label }) => (
<Link href={href} key={href}>
<a className={pathname === href ? 'nav-link active' : 'nav-link'} aria-current={pathname === href ? 'page' : undefined} onClick={closeMenu}>
{label}
</a>
</Link>
))}
<details className='more-menu'>
<summary className={moreIsActive ? 'nav-link active' : 'nav-link'}>
بیشتر <FiChevronDown aria-hidden='true' />
</summary>
<div className='more-panel'>
{moreLinks.map(({ href, label }) => (
<Link href={href} key={href}>
<a aria-current={pathname === href ? 'page' : undefined} onClick={closeMenu}>
{label}
</a>
</Link>
))}
</div>
</details>
</div>
<Link href='/page/contact-us'>
<a className='contact-button' onClick={closeMenu}>تماس با ما</a>
</Link>
</nav>
</div>
</div>
<style jsx>{`
.site-header {
position: relative;
z-index: 30;
width: 100%;
font-family: dana-fanum, sans-serif;
}
.header-container {
width: calc(100% - 40px);
max-width: 1240px;
margin: 0 auto;
}
.topbar {
color: #e6f6f5;
background: #12464e;
}
.topbar-inner,
.topbar-location,
.topbar-actions,
.phone-link {
display: flex;
align-items: center;
}
.topbar-inner {
min-height: 42px;
justify-content: space-between;
gap: 20px;
font-size: 12px;
}
.topbar-location,
.topbar-actions,
.phone-link {
gap: 9px;
}
.topbar-location {
min-width: 0;
}
.topbar-location span {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.topbar a {
color: inherit;
text-decoration: none;
}
.topbar a:hover {
color: #89e1da;
}
.topbar-actions {
flex-shrink: 0;
}
.topbar-divider {
width: 1px;
height: 17px;
background: rgba(255, 255, 255, .25);
}
.social-link {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
font-size: 17px;
}
.mainbar {
background: #fff;
box-shadow: 0 7px 24px rgba(13, 71, 76, .08);
}
.mainbar-inner {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 84px;
gap: 28px;
}
.brand {
display: inline-flex;
align-items: center;
flex-shrink: 0;
gap: 11px;
color: #164a50;
text-decoration: none;
}
.brand:hover {
color: #164a50;
}
.brand img {
display: block;
width: 56px;
height: 53px;
object-fit: contain;
}
.brand-copy {
display: flex;
flex-direction: column;
line-height: 1.55;
}
.brand-copy strong {
font-size: 18px;
font-weight: 800;
}
.brand-copy small {
color: #6c898d;
font-size: 11px;
}
.navigation,
.nav-links {
display: flex;
align-items: center;
}
.navigation {
justify-content: space-between;
flex: 1;
min-width: 0;
gap: 20px;
}
.nav-links {
gap: 2px;
}
.nav-link {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 5px;
padding: 12px 10px;
border: 0;
border-radius: 10px;
color: #34575b;
font-size: 13px;
font-weight: 700;
white-space: nowrap;
text-decoration: none;
cursor: pointer;
transition: color .2s ease, background-color .2s ease;
}
.nav-link:hover,
.nav-link.active,
.more-menu[open] > .nav-link {
color: #147f80;
background: #eaf7f5;
}
.more-menu {
position: relative;
}
.more-menu summary {
list-style: none;
}
.more-menu summary::-webkit-details-marker {
display: none;
}
.more-panel {
position: absolute;
top: calc(100% + 10px);
right: 0;
z-index: 10;
min-width: 162px;
padding: 7px;
border: 1px solid #e0efed;
border-radius: 14px;
background: #fff;
box-shadow: 0 14px 32px rgba(21, 72, 77, .14);
}
.more-panel a {
display: block;
padding: 10px 12px;
border-radius: 8px;
color: #34575b;
font-size: 13px;
text-decoration: none;
white-space: nowrap;
}
.more-panel a:hover,
.more-panel a[aria-current='page'] {
color: #147f80;
background: #eaf7f5;
}
.contact-button {
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
min-height: 42px;
padding: 0 18px;
border-radius: 11px;
color: #fff;
background: #168b89;
font-size: 13px;
font-weight: 700;
text-decoration: none;
white-space: nowrap;
transition: background-color .2s ease, transform .2s ease;
}
.contact-button:hover {
color: #fff;
background: #106e70;
transform: translateY(-2px);
}
.menu-toggle {
display: none;
align-items: center;
justify-content: center;
width: 44px;
height: 44px;
border: 1px solid #d7e9e7;
border-radius: 11px;
color: #176f73;
background: #f2f9f8;
font-size: 22px;
cursor: pointer;
}
.site-header a:focus-visible,
.site-header button:focus-visible,
.site-header summary:focus-visible {
outline: 3px solid #57c5c6;
outline-offset: 3px;
}
@media (max-width: 1100px) {
.mainbar-inner {
position: relative;
min-height: 74px;
}
.menu-toggle {
display: inline-flex;
}
.navigation {
display: none;
position: absolute;
top: 100%;
right: 0;
left: 0;
z-index: 20;
flex-direction: column;
align-items: stretch;
gap: 12px;
max-height: calc(100vh - 116px);
overflow-y: auto;
padding: 15px;
border: 1px solid #e0efed;
border-radius: 0 0 16px 16px;
background: #fff;
box-shadow: 0 17px 30px rgba(21, 72, 77, .14);
}
.navigation.is-open,
.nav-links {
display: flex;
}
.nav-links {
flex-direction: column;
align-items: stretch;
}
.nav-link {
display: flex;
justify-content: space-between;
padding: 12px 14px;
}
.more-panel {
position: static;
margin: 4px 12px 8px;
box-shadow: none;
}
.contact-button {
width: 100%;
}
}
@media (max-width: 700px) {
.header-container {
width: calc(100% - 32px);
}
.topbar-inner {
min-height: 36px;
justify-content: center;
}
.topbar-location {
display: none;
}
.mainbar-inner {
min-height: 68px;
}
.brand img {
width: 47px;
height: 45px;
}
.brand-copy strong {
font-size: 15px;
}
.brand-copy small {
font-size: 10px;
}
.navigation {
max-height: calc(100vh - 104px);
}
}
`}</style>
</header>
)
}