64 lines
2.1 KiB
TypeScript
64 lines
2.1 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
import { Sidebar } from "./Sidebar";
|
|
import { Menu, X } from "lucide-react";
|
|
import { motion, AnimatePresence } from "framer-motion";
|
|
|
|
export function MobileNav() {
|
|
const [isOpen, setIsOpen] = useState(false);
|
|
|
|
return (
|
|
<div className="md:hidden">
|
|
<div className="flex h-16 items-center justify-between border-b border-border bg-card px-4">
|
|
<div className="flex items-center gap-2">
|
|
<div className="h-8 w-8 rounded-lg bg-primary flex items-center justify-center">
|
|
<span className="text-primary-foreground font-bold">R</span>
|
|
</div>
|
|
<span className="text-lg font-display font-bold text-primary">ReservaMesa</span>
|
|
</div>
|
|
<button
|
|
onClick={() => setIsOpen(true)}
|
|
className="rounded-md p-2 text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
|
>
|
|
<Menu className="h-6 w-6" />
|
|
</button>
|
|
</div>
|
|
|
|
<AnimatePresence>
|
|
{isOpen && (
|
|
<>
|
|
{/* Backdrop */}
|
|
<motion.div
|
|
initial={{ opacity: 0 }}
|
|
animate={{ opacity: 1 }}
|
|
exit={{ opacity: 0 }}
|
|
onClick={() => setIsOpen(false)}
|
|
className="fixed inset-0 z-40 bg-background/80 backdrop-blur-sm"
|
|
/>
|
|
|
|
{/* Sidebar */}
|
|
<motion.div
|
|
initial={{ x: "-100%" }}
|
|
animate={{ x: 0 }}
|
|
exit={{ x: "-100%" }}
|
|
transition={{ type: "spring", damping: 25, stiffness: 200 }}
|
|
className="fixed inset-y-0 left-0 z-50 w-64 shadow-2xl"
|
|
>
|
|
<div className="relative h-full w-full">
|
|
<button
|
|
onClick={() => setIsOpen(false)}
|
|
className="absolute right-4 top-4 z-50 rounded-md p-2 text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
|
>
|
|
<X className="h-6 w-6" />
|
|
</button>
|
|
<Sidebar />
|
|
</div>
|
|
</motion.div>
|
|
</>
|
|
)}
|
|
</AnimatePresence>
|
|
</div>
|
|
);
|
|
}
|