56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
|
|
export function MobileNav({ children }: { children: React.ReactNode }) {
|
|
const [open, setOpen] = useState(false);
|
|
|
|
return (
|
|
<>
|
|
<button
|
|
type="button"
|
|
onClick={() => setOpen(!open)}
|
|
className="flex md:hidden items-center justify-center w-10 h-10 rounded-lg transition-colors duration-150"
|
|
style={{ color: "var(--color-navbar-text)" }}
|
|
aria-label={open ? "Sluit menu" : "Open menu"}
|
|
>
|
|
<svg className="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
{open ? (
|
|
<>
|
|
<line x1="18" y1="6" x2="6" y2="18" />
|
|
<line x1="6" y1="6" x2="18" y2="18" />
|
|
</>
|
|
) : (
|
|
<>
|
|
<line x1="3" y1="6" x2="21" y2="6" />
|
|
<line x1="3" y1="12" x2="21" y2="12" />
|
|
<line x1="3" y1="18" x2="21" y2="18" />
|
|
</>
|
|
)}
|
|
</svg>
|
|
</button>
|
|
|
|
{open && (
|
|
<div
|
|
className="fixed inset-0 z-30 md:hidden"
|
|
onClick={() => setOpen(false)}
|
|
style={{ backgroundColor: "rgba(0,0,0,0.4)" }}
|
|
/>
|
|
)}
|
|
|
|
<div
|
|
className={`${open ? "max-h-[80vh] opacity-100" : "max-h-0 opacity-0 pointer-events-none md:pointer-events-auto"} overflow-hidden transition-all duration-300 ease-in-out md:!max-h-none md:!opacity-100 md:!overflow-visible md:flex md:items-center md:gap-x-1 w-full md:w-auto`}
|
|
style={{ backgroundColor: "var(--color-navbar)" }}
|
|
>
|
|
<div
|
|
className="flex flex-col md:flex-row md:items-center gap-y-0.5 p-3 md:p-0 rounded-xl md:rounded-none border md:border-0 shadow-lg md:shadow-none mt-2 md:mt-0"
|
|
style={{
|
|
borderColor: "color-mix(in srgb, var(--color-text-muted) 10%, transparent)",
|
|
}}
|
|
>
|
|
{children}
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
} |