Download frontend/src/components/Layout.tsx from xunwei/fitAI: direct link, hf CLI and curl.
- Browser
- Download file 1.7 kB
-
https://huggingface.co/spaces/xunwei/fitAI/resolve/main/frontend/src/components/Layout.tsx
- Command line
-
hf download hf://spaces/xunwei/fitAI/frontend/src/components/Layout.tsx
-
curl -L -o Layout.tsx https://huggingface.co/spaces/xunwei/fitAI/resolve/main/frontend/src/components/Layout.tsx
1.7 kB
| import { Outlet, NavLink, useNavigate } from 'react-router-dom' | |
| const navItems = [ | |
| { to: '/', label: '🏠 Dashboard', end: true }, | |
| { to: '/workouts', label: '💪 Workouts' }, | |
| { to: '/health', label: '❤️ Health' }, | |
| { to: '/chat', label: '🤖 AI Coach' }, | |
| ] | |
| export default function Layout() { | |
| const navigate = useNavigate() | |
| function logout() { | |
| localStorage.removeItem('token') | |
| navigate('/login') | |
| } | |
| return ( | |
| <div className="flex flex-col min-h-screen"> | |
| {/* Top nav */} | |
| <header className="bg-indigo-600 text-white px-4 py-3 flex items-center justify-between shadow"> | |
| <span className="font-bold text-lg tracking-tight">⚡ FitAI Coach</span> | |
| <button | |
| onClick={logout} | |
| className="text-sm bg-indigo-500 hover:bg-indigo-400 px-3 py-1 rounded transition" | |
| > | |
| Logout | |
| </button> | |
| </header> | |
| <div className="flex flex-1"> | |
| {/* Sidebar */} | |
| <nav className="w-44 bg-white border-r flex flex-col gap-1 p-3 shrink-0"> | |
| {navItems.map(({ to, label, end }) => ( | |
| <NavLink | |
| key={to} | |
| to={to} | |
| end={end} | |
| className={({ isActive }) => | |
| `px-3 py-2 rounded text-sm font-medium transition ${ | |
| isActive | |
| ? 'bg-indigo-50 text-indigo-700' | |
| : 'text-gray-600 hover:bg-gray-100' | |
| }` | |
| } | |
| > | |
| {label} | |
| </NavLink> | |
| ))} | |
| </nav> | |
| {/* Main content */} | |
| <main className="flex-1 p-6 overflow-auto"> | |
| <Outlet /> | |
| </main> | |
| </div> | |
| </div> | |
| ) | |
| } | |