Spaces:
Sleeping
Sleeping
axeronis commited on
Commit ·
36a8ee1
1
Parent(s): 6d9f4f9
feat: add mobile bottom navigation bar for better UX
Browse files
frontend/app/layout.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import { useAuth } from '@/contexts/AuthContext'
|
|
| 12 |
import { useEffect } from 'react'
|
| 13 |
import { useRouter } from 'next/navigation'
|
| 14 |
import { MobileHeader, MobileSidebarWrapper } from '@/components/MobileNav'
|
|
|
|
| 15 |
|
| 16 |
const inter = Inter({ subsets: ['latin', 'cyrillic'] })
|
| 17 |
|
|
@@ -69,21 +70,26 @@ export default function RootLayout({
|
|
| 69 |
<Sidebar />
|
| 70 |
</div>
|
| 71 |
|
| 72 |
-
{/* Mobile Sidebar (Drawer) */}
|
| 73 |
<MobileSidebarWrapper>
|
| 74 |
<Sidebar />
|
| 75 |
</MobileSidebarWrapper>
|
| 76 |
|
| 77 |
{/* Main Content Area Container */}
|
| 78 |
<div className="flex-1 flex flex-col h-full min-w-0 transition-all duration-300 relative">
|
| 79 |
-
{/* Header
|
| 80 |
<Header />
|
|
|
|
|
|
|
| 81 |
<MobileHeader />
|
| 82 |
|
| 83 |
-
{/* Scrollable Content */}
|
| 84 |
-
<main className="flex-1 overflow-y-auto w-full relative">
|
| 85 |
{children}
|
| 86 |
</main>
|
|
|
|
|
|
|
|
|
|
| 87 |
</div>
|
| 88 |
</div>
|
| 89 |
</ProtectedLayout>
|
|
|
|
| 12 |
import { useEffect } from 'react'
|
| 13 |
import { useRouter } from 'next/navigation'
|
| 14 |
import { MobileHeader, MobileSidebarWrapper } from '@/components/MobileNav'
|
| 15 |
+
import { MobileBottomNav } from '@/components/MobileBottomNav'
|
| 16 |
|
| 17 |
const inter = Inter({ subsets: ['latin', 'cyrillic'] })
|
| 18 |
|
|
|
|
| 70 |
<Sidebar />
|
| 71 |
</div>
|
| 72 |
|
| 73 |
+
{/* Mobile Sidebar (Drawer - opens from menu button) */}
|
| 74 |
<MobileSidebarWrapper>
|
| 75 |
<Sidebar />
|
| 76 |
</MobileSidebarWrapper>
|
| 77 |
|
| 78 |
{/* Main Content Area Container */}
|
| 79 |
<div className="flex-1 flex flex-col h-full min-w-0 transition-all duration-300 relative">
|
| 80 |
+
{/* Desktop Header */}
|
| 81 |
<Header />
|
| 82 |
+
|
| 83 |
+
{/* Mobile Header - simplified, just logo */}
|
| 84 |
<MobileHeader />
|
| 85 |
|
| 86 |
+
{/* Scrollable Content - with padding for bottom nav on mobile */}
|
| 87 |
+
<main className="flex-1 overflow-y-auto w-full relative pb-16 md:pb-0">
|
| 88 |
{children}
|
| 89 |
</main>
|
| 90 |
+
|
| 91 |
+
{/* Mobile Bottom Navigation */}
|
| 92 |
+
<MobileBottomNav />
|
| 93 |
</div>
|
| 94 |
</div>
|
| 95 |
</ProtectedLayout>
|
frontend/components/MobileBottomNav.tsx
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import Link from 'next/link'
|
| 4 |
+
import { usePathname } from 'next/navigation'
|
| 5 |
+
import {
|
| 6 |
+
LayoutDashboard,
|
| 7 |
+
MessageSquare,
|
| 8 |
+
Calendar,
|
| 9 |
+
Menu,
|
| 10 |
+
X
|
| 11 |
+
} from 'lucide-react'
|
| 12 |
+
import { useState } from 'react'
|
| 13 |
+
import { cn } from '@/lib/utils'
|
| 14 |
+
import { useTranslation } from '@/lib/i18n'
|
| 15 |
+
|
| 16 |
+
const navItems = [
|
| 17 |
+
{ href: '/dashboard', icon: LayoutDashboard, label: 'Главная' },
|
| 18 |
+
{ href: '/chats', icon: MessageSquare, label: 'Чаты' },
|
| 19 |
+
{ href: '/appointments', icon: Calendar, label: 'Записи' },
|
| 20 |
+
]
|
| 21 |
+
|
| 22 |
+
export function MobileBottomNav() {
|
| 23 |
+
const pathname = usePathname()
|
| 24 |
+
const [menuOpen, setMenuOpen] = useState(false)
|
| 25 |
+
const { t } = useTranslation()
|
| 26 |
+
|
| 27 |
+
const isActive = (path: string) => pathname === path || pathname.startsWith(path + '/')
|
| 28 |
+
|
| 29 |
+
return (
|
| 30 |
+
<>
|
| 31 |
+
{/* Bottom Navigation Bar - only on mobile */}
|
| 32 |
+
<nav className="md:hidden fixed bottom-0 left-0 right-0 z-50 bg-[#0F172A] border-t border-slate-800 safe-area-bottom">
|
| 33 |
+
<div className="flex items-center justify-around h-16 px-2">
|
| 34 |
+
{navItems.map((item) => {
|
| 35 |
+
const Icon = item.icon
|
| 36 |
+
const active = isActive(item.href)
|
| 37 |
+
|
| 38 |
+
return (
|
| 39 |
+
<Link
|
| 40 |
+
key={item.href}
|
| 41 |
+
href={item.href}
|
| 42 |
+
className={cn(
|
| 43 |
+
"flex flex-col items-center justify-center flex-1 py-2 px-1 rounded-lg transition-all",
|
| 44 |
+
active
|
| 45 |
+
? "text-indigo-400"
|
| 46 |
+
: "text-slate-400 hover:text-slate-200"
|
| 47 |
+
)}
|
| 48 |
+
>
|
| 49 |
+
<Icon className={cn("w-6 h-6 mb-1", active && "text-indigo-400")} />
|
| 50 |
+
<span className={cn(
|
| 51 |
+
"text-xs font-medium",
|
| 52 |
+
active && "text-indigo-400"
|
| 53 |
+
)}>
|
| 54 |
+
{item.label}
|
| 55 |
+
</span>
|
| 56 |
+
{active && (
|
| 57 |
+
<div className="absolute bottom-1 w-1 h-1 bg-indigo-400 rounded-full" />
|
| 58 |
+
)}
|
| 59 |
+
</Link>
|
| 60 |
+
)
|
| 61 |
+
})}
|
| 62 |
+
|
| 63 |
+
{/* Menu Button */}
|
| 64 |
+
<button
|
| 65 |
+
onClick={() => document.dispatchEvent(new CustomEvent('toggle-mobile-sidebar'))}
|
| 66 |
+
className="flex flex-col items-center justify-center flex-1 py-2 px-1 rounded-lg text-slate-400 hover:text-slate-200 transition-all"
|
| 67 |
+
>
|
| 68 |
+
<Menu className="w-6 h-6 mb-1" />
|
| 69 |
+
<span className="text-xs font-medium">Меню</span>
|
| 70 |
+
</button>
|
| 71 |
+
</div>
|
| 72 |
+
</nav>
|
| 73 |
+
</>
|
| 74 |
+
)
|
| 75 |
+
}
|