mucahitkantepe's picture
Add mobile responsive layout with bottom tab bar
88e0098
Raw History Blame Contribute Delete
2.69 kB
import { NavLink, Outlet } from "react-router-dom";
function BrowseIcon() {
return (
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
<rect x="3" y="3" width="7" height="7" />
<rect x="14" y="3" width="7" height="7" />
<rect x="3" y="14" width="7" height="7" />
<rect x="14" y="14" width="7" height="7" />
</svg>
);
}
function ProfileIcon() {
return (
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
<circle cx="12" cy="7" r="4" />
</svg>
);
}
function DiscoverIcon() {
return (
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
<circle cx="12" cy="12" r="10" />
<circle cx="12" cy="12" r="3" />
<line x1="12" y1="2" x2="12" y2="6" />
<line x1="12" y1="18" x2="12" y2="22" />
<line x1="2" y1="12" x2="6" y2="12" />
<line x1="18" y1="12" x2="22" y2="12" />
</svg>
);
}
function DashboardIcon() {
return (
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
<path d="M3 3v18h18" />
<path d="M18 17V9" />
<path d="M13 17V5" />
<path d="M8 17v-3" />
</svg>
);
}
const navItems: { to: string; end?: boolean; icon: () => React.JSX.Element; label: string }[] = [
{ to: "/", end: true, icon: BrowseIcon, label: "Browse" },
{ to: "/discover", icon: DiscoverIcon, label: "Discover" },
{ to: "/profile", icon: ProfileIcon, label: "Profile" },
{ to: "/dashboard", icon: DashboardIcon, label: "Dashboard" },
];
export function Layout() {
return (
<div className="app-shell">
<aside className="sidebar">
<div className="sidebar-brand">
<span>Taste</span> Engine
</div>
<nav>
{navItems.map(({ to, end, icon: Icon, label }) => (
<NavLink key={to} to={to} end={end} className={({ isActive }) => isActive ? "active" : ""}>
<Icon />
{label}
</NavLink>
))}
</nav>
</aside>
<main className="main-content">
<Outlet />
</main>
<nav className="mobile-tab-bar">
{navItems.map(({ to, end, icon: Icon, label }) => (
<NavLink key={to} to={to} end={end} className={({ isActive }) => `tab-item${isActive ? " active" : ""}`}>
<Icon />
<span>{label}</span>
</NavLink>
))}
</nav>
</div>
);
}