Spaces:
Running
Running
axeronis commited on
Commit ·
0acf249
1
Parent(s): 2123e82
feat: Mobile footer (bottom nav) now smoothly hides when sidebar is open and reappears on close/navigation
Browse files
frontend/components/MobileBottomNav.tsx
CHANGED
|
@@ -9,12 +9,33 @@ import {
|
|
| 9 |
Menu
|
| 10 |
} from 'lucide-react'
|
| 11 |
import { cn } from '@/lib/utils'
|
|
|
|
|
|
|
| 12 |
|
| 13 |
export function MobileBottomNav() {
|
| 14 |
const pathname = usePathname()
|
| 15 |
const router = useRouter()
|
| 16 |
|
| 17 |
const isActive = (path: string) => pathname === path || pathname.startsWith(path + '/')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
const handleChatsClick = () => {
|
| 20 |
// Dispatch custom event to reset chats view (clear selection on mobile)
|
|
@@ -23,55 +44,65 @@ export function MobileBottomNav() {
|
|
| 23 |
}
|
| 24 |
|
| 25 |
return (
|
| 26 |
-
<
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
? "text-indigo-400 bg-indigo-500/10"
|
| 35 |
-
: "text-slate-500 active:bg-white/5"
|
| 36 |
-
)}
|
| 37 |
>
|
| 38 |
-
<
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
| 76 |
)
|
| 77 |
}
|
|
|
|
| 9 |
Menu
|
| 10 |
} from 'lucide-react'
|
| 11 |
import { cn } from '@/lib/utils'
|
| 12 |
+
import { motion, AnimatePresence } from 'framer-motion'
|
| 13 |
+
import { useState, useEffect } from 'react'
|
| 14 |
|
| 15 |
export function MobileBottomNav() {
|
| 16 |
const pathname = usePathname()
|
| 17 |
const router = useRouter()
|
| 18 |
|
| 19 |
const isActive = (path: string) => pathname === path || pathname.startsWith(path + '/')
|
| 20 |
+
const [isSidebarOpen, setIsSidebarOpen] = useState(false)
|
| 21 |
+
|
| 22 |
+
useEffect(() => {
|
| 23 |
+
const handleToggle = () => setIsSidebarOpen(prev => !prev)
|
| 24 |
+
const handleClose = () => setIsSidebarOpen(false)
|
| 25 |
+
|
| 26 |
+
document.addEventListener('toggle-mobile-sidebar', handleToggle)
|
| 27 |
+
document.addEventListener('close-mobile-sidebar', handleClose)
|
| 28 |
+
|
| 29 |
+
return () => {
|
| 30 |
+
document.removeEventListener('toggle-mobile-sidebar', handleToggle)
|
| 31 |
+
document.removeEventListener('close-mobile-sidebar', handleClose)
|
| 32 |
+
}
|
| 33 |
+
}, [])
|
| 34 |
+
|
| 35 |
+
// Ensure footer shows up on route change
|
| 36 |
+
useEffect(() => {
|
| 37 |
+
setIsSidebarOpen(false)
|
| 38 |
+
}, [pathname])
|
| 39 |
|
| 40 |
const handleChatsClick = () => {
|
| 41 |
// Dispatch custom event to reset chats view (clear selection on mobile)
|
|
|
|
| 44 |
}
|
| 45 |
|
| 46 |
return (
|
| 47 |
+
<AnimatePresence>
|
| 48 |
+
{!isSidebarOpen && (
|
| 49 |
+
<motion.nav
|
| 50 |
+
initial={{ y: '100%' }}
|
| 51 |
+
animate={{ y: 0 }}
|
| 52 |
+
exit={{ y: '100%' }}
|
| 53 |
+
transition={{ type: 'spring', damping: 20, stiffness: 200 }}
|
| 54 |
+
className="fixed bottom-0 left-0 right-0 z-40 bg-gradient-to-t from-black/80 via-black/40 to-transparent backdrop-blur-xl safe-area-bottom"
|
|
|
|
|
|
|
|
|
|
| 55 |
>
|
| 56 |
+
<div className="flex items-center justify-around h-14 px-4">
|
| 57 |
+
{/* Главная */}
|
| 58 |
+
<Link
|
| 59 |
+
href="/dashboard"
|
| 60 |
+
className={cn(
|
| 61 |
+
"flex flex-col items-center justify-center p-2 rounded-xl transition-all",
|
| 62 |
+
isActive('/dashboard')
|
| 63 |
+
? "text-indigo-400 bg-indigo-500/10"
|
| 64 |
+
: "text-slate-500 active:bg-white/5"
|
| 65 |
+
)}
|
| 66 |
+
>
|
| 67 |
+
<LayoutDashboard className="w-5 h-5" />
|
| 68 |
+
</Link>
|
| 69 |
|
| 70 |
+
{/* Чаты */}
|
| 71 |
+
<button
|
| 72 |
+
onClick={handleChatsClick}
|
| 73 |
+
className={cn(
|
| 74 |
+
"flex flex-col items-center justify-center p-2 rounded-xl transition-all",
|
| 75 |
+
isActive('/chats')
|
| 76 |
+
? "text-indigo-400 bg-indigo-500/10"
|
| 77 |
+
: "text-slate-500 active:bg-white/5"
|
| 78 |
+
)}
|
| 79 |
+
>
|
| 80 |
+
<MessageSquare className="w-5 h-5" />
|
| 81 |
+
</button>
|
| 82 |
|
| 83 |
+
{/* Записи */}
|
| 84 |
+
<Link
|
| 85 |
+
href="/appointments"
|
| 86 |
+
className={cn(
|
| 87 |
+
"flex flex-col items-center justify-center p-2 rounded-xl transition-all",
|
| 88 |
+
isActive('/appointments')
|
| 89 |
+
? "text-indigo-400 bg-indigo-500/10"
|
| 90 |
+
: "text-slate-500 active:bg-white/5"
|
| 91 |
+
)}
|
| 92 |
+
>
|
| 93 |
+
<Calendar className="w-5 h-5" />
|
| 94 |
+
</Link>
|
| 95 |
|
| 96 |
+
{/* Menu */}
|
| 97 |
+
<button
|
| 98 |
+
onClick={() => document.dispatchEvent(new CustomEvent('toggle-mobile-sidebar'))}
|
| 99 |
+
className="flex flex-col items-center justify-center p-2 rounded-xl text-slate-500 active:bg-white/5 transition-all"
|
| 100 |
+
>
|
| 101 |
+
<Menu className="w-5 h-5" />
|
| 102 |
+
</button>
|
| 103 |
+
</div>
|
| 104 |
+
</motion.nav>
|
| 105 |
+
)}
|
| 106 |
+
</AnimatePresence>
|
| 107 |
)
|
| 108 |
}
|
frontend/components/MobileNav.tsx
CHANGED
|
@@ -156,7 +156,7 @@ export function MobileSidebarWrapper({ children }: { children: React.ReactNode }
|
|
| 156 |
animate={{ x: 0 }}
|
| 157 |
exit={{ x: '-100%' }}
|
| 158 |
transition={{ type: 'spring', damping: 25, stiffness: 200 }}
|
| 159 |
-
className="fixed left-0 top-16 bottom-
|
| 160 |
>
|
| 161 |
{children}
|
| 162 |
</motion.div>
|
|
|
|
| 156 |
animate={{ x: 0 }}
|
| 157 |
exit={{ x: '-100%' }}
|
| 158 |
transition={{ type: 'spring', damping: 25, stiffness: 200 }}
|
| 159 |
+
className="fixed left-0 top-16 bottom-0 w-72 bg-gradient-to-r from-black/80 to-black/60 backdrop-blur-2xl z-50 shadow-2xl overflow-hidden border-r border-white/5"
|
| 160 |
>
|
| 161 |
{children}
|
| 162 |
</motion.div>
|