Spaces:
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
- <nav 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">
27
- <div className="flex items-center justify-around h-14 px-4">
28
- {/* Главная */}
29
- <Link
30
- href="/dashboard"
31
- className={cn(
32
- "flex flex-col items-center justify-center p-2 rounded-xl transition-all",
33
- isActive('/dashboard')
34
- ? "text-indigo-400 bg-indigo-500/10"
35
- : "text-slate-500 active:bg-white/5"
36
- )}
37
  >
38
- <LayoutDashboard className="w-5 h-5" />
39
- </Link>
 
 
 
 
 
 
 
 
 
 
 
40
 
41
- {/* Чаты */}
42
- <button
43
- onClick={handleChatsClick}
44
- className={cn(
45
- "flex flex-col items-center justify-center p-2 rounded-xl transition-all",
46
- isActive('/chats')
47
- ? "text-indigo-400 bg-indigo-500/10"
48
- : "text-slate-500 active:bg-white/5"
49
- )}
50
- >
51
- <MessageSquare className="w-5 h-5" />
52
- </button>
53
 
54
- {/* Записи */}
55
- <Link
56
- href="/appointments"
57
- className={cn(
58
- "flex flex-col items-center justify-center p-2 rounded-xl transition-all",
59
- isActive('/appointments')
60
- ? "text-indigo-400 bg-indigo-500/10"
61
- : "text-slate-500 active:bg-white/5"
62
- )}
63
- >
64
- <Calendar className="w-5 h-5" />
65
- </Link>
66
 
67
- {/* Menu */}
68
- <button
69
- onClick={() => document.dispatchEvent(new CustomEvent('toggle-mobile-sidebar'))}
70
- className="flex flex-col items-center justify-center p-2 rounded-xl text-slate-500 active:bg-white/5 transition-all"
71
- >
72
- <Menu className="w-5 h-5" />
73
- </button>
74
- </div>
75
- </nav>
 
 
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-14 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>
 
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>