mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 15:07:13 +01:00
add hamburger for mobile
This commit is contained in:
@@ -1,17 +1,47 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
import User from './user'
|
import User from './user'
|
||||||
|
|
||||||
|
const NAV_ENTRIES = [
|
||||||
|
{
|
||||||
|
label: 'Home',
|
||||||
|
href: '/',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Buchungsanfrage',
|
||||||
|
href: '/book',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Preise',
|
||||||
|
href: '/prices',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Mietbedingungen',
|
||||||
|
href: '/terms',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
export default function Header() {
|
export default function Header() {
|
||||||
|
const router = useRouter()
|
||||||
|
const [hamburgerOpen, setHamburgerOpen] = useState(false)
|
||||||
|
|
||||||
|
function changeRoute(event: React.PointerEvent<HTMLAnchorElement>) {
|
||||||
|
event.preventDefault()
|
||||||
|
setHamburgerOpen(false)
|
||||||
|
router.push(event.currentTarget.href)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>Pfadi-Bussle</title>
|
<title>Pfadi-Bussle</title>
|
||||||
<link rel="icon" href="/favicon.ico" />
|
<link rel="icon" href="/favicon.ico" />
|
||||||
</Head>
|
</Head>
|
||||||
<div className="relative bg-white">
|
<div className="">
|
||||||
<div className="max-w-7xl mx-auto px-4 sm:px-6">
|
<div className="max-w-7xl mx-auto px-4 sm:px-6">
|
||||||
<div className="flex justify-between items-center border-b-2 border-gray-100 py-6 md:justify-start md:space-x-10">
|
<div className="relative flex justify-between items-center border-b-2 border-gray-100 py-6 md:justify-start md:space-x-10">
|
||||||
<div className="flex justify-start lg:w-0 flex-1">
|
<div className="flex justify-start lg:w-0 flex-1">
|
||||||
<Link href="/">
|
<Link href="/">
|
||||||
<a className="text-lg tracking-tight font-extrabold text-blue-800 sm:text-xl md:text-2xl">
|
<a className="text-lg tracking-tight font-extrabold text-blue-800 sm:text-xl md:text-2xl">
|
||||||
@@ -20,26 +50,26 @@ export default function Header() {
|
|||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<nav className="hidden space-x-10 sm:flex">
|
<nav className="hidden space-x-10 sm:flex">
|
||||||
<Link href="/book">
|
{NAV_ENTRIES.map(({ label, href }) => {
|
||||||
<a className="text-base font-medium text-gray-500 hover:text-gray-900">
|
return (
|
||||||
Buchungsanfrage
|
<a
|
||||||
</a>
|
key={href}
|
||||||
</Link>
|
href={href}
|
||||||
<Link href="/prices">
|
onClick={changeRoute}
|
||||||
<a className="text-base font-medium text-gray-500 hover:text-gray-900">
|
className="text-base font-medium text-gray-500 hover:text-gray-900"
|
||||||
Preise
|
>
|
||||||
</a>
|
{label}
|
||||||
</Link>
|
</a>
|
||||||
<Link href="/terms">
|
)
|
||||||
<a className="text-base font-medium text-gray-500 hover:text-gray-900">
|
})}
|
||||||
Mitbedingungen
|
|
||||||
</a>
|
|
||||||
</Link>
|
|
||||||
</nav>
|
</nav>
|
||||||
<nav className="sm:hidden">
|
<nav
|
||||||
|
onClick={() => setHamburgerOpen(!hamburgerOpen)}
|
||||||
|
className="flex flex-col sm:hidden text-gray-500 hover:text-gray-900 cursor-pointer"
|
||||||
|
>
|
||||||
<svg
|
<svg
|
||||||
|
className="w-5"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width="24"
|
|
||||||
fill="none"
|
fill="none"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
@@ -51,6 +81,28 @@ export default function Header() {
|
|||||||
d="M4 6h16M4 12h16M4 18h16"
|
d="M4 6h16M4 12h16M4 18h16"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
|
<div
|
||||||
|
className={`${
|
||||||
|
hamburgerOpen || 'hidden'
|
||||||
|
} absolute z-10 mt-5 transform right-0`}
|
||||||
|
>
|
||||||
|
<div className="rounded-lg shadow-lg ring-1 ring-black ring-opacity-5 overflow-hidden">
|
||||||
|
<div className="relative grid gap-2 bg-white px-4 py-2">
|
||||||
|
{NAV_ENTRIES.map(({ label, href }) => {
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
key={href}
|
||||||
|
href={href}
|
||||||
|
onClick={changeRoute}
|
||||||
|
className="text-base font-medium text-gray-500 hover:text-gray-900"
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<User />
|
<User />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user