Spaces:
Runtime error
Runtime error
File size: 1,141 Bytes
c16d5c1 6aa6081 c16d5c1 6aa6081 d456a34 c16d5c1 6aa6081 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import { Outlet, useLocation } from 'react-router-dom';
import { useState, useEffect } from 'react';
import { Menu } from 'lucide-react';
import Sidebar from './Sidebar';
export default function Layout() {
const [mobileOpen, setMobileOpen] = useState(false);
const location = useLocation();
// Close drawer whenever the route changes.
useEffect(() => {
setMobileOpen(false);
}, [location.pathname]);
return (
<div className="app-layout">
{/* Floating hamburger (mobile only, no full topbar) */}
<button
type="button"
onClick={() => setMobileOpen(true)}
aria-label="Abrir menú"
className="mobile-menu-fab md:hidden"
>
<Menu size={20} />
</button>
{/* Backdrop for mobile drawer */}
{mobileOpen && (
<div
className="fixed inset-0 bg-black/50 z-30 md:hidden"
onClick={() => setMobileOpen(false)}
aria-hidden="true"
/>
)}
<Sidebar mobileOpen={mobileOpen} onClose={() => setMobileOpen(false)} />
<main className="main-content">
<Outlet />
</main>
</div>
);
}
|