Spaces:
Running

microfunnel-api / frontend /components /MobileBottomNav.tsx
axeronis
fix(ui): integrate ImageViewer, refactor voice logic, fix input padding
cb528a9
Raw History Blame Contribute Delete
4.77 kB
'use client'
import Link from 'next/link'
import { usePathname, useRouter } from 'next/navigation'
import {
LayoutDashboard,
MessageSquare,
Calendar,
Menu,
Bot,
Brain
} from 'lucide-react'
import { cn } from '@/lib/utils'
import { motion, AnimatePresence } from 'framer-motion'
import { useState, useEffect } from 'react'
export function MobileBottomNav() {
const pathname = usePathname()
const router = useRouter()
const isActive = (path: string) => pathname === path || pathname.startsWith(path + '/')
const [isSidebarOpen, setIsSidebarOpen] = useState(false)
useEffect(() => {
const handleToggle = () => setIsSidebarOpen(prev => !prev)
const handleClose = () => setIsSidebarOpen(false)
document.addEventListener('toggle-mobile-sidebar', handleToggle)
document.addEventListener('close-mobile-sidebar', handleClose)
return () => {
document.removeEventListener('toggle-mobile-sidebar', handleToggle)
document.removeEventListener('close-mobile-sidebar', handleClose)
}
}, [])
// Ensure footer shows up on route change
useEffect(() => {
setIsSidebarOpen(false)
}, [pathname])
const handleChatsClick = () => {
// Dispatch custom event to reset chats view (clear selection on mobile)
document.dispatchEvent(new CustomEvent('reset-chats-view'))
router.push('/chats')
}
return (
<AnimatePresence>
{!isSidebarOpen && (
<motion.nav
initial={{ y: '100%' }}
animate={{ y: 0 }}
exit={{ y: '100%' }}
transition={{ type: 'spring', damping: 20, stiffness: 200 }}
className="fixed bottom-0 left-0 right-0 z-40 bg-gradient-to-t from-black via-[#050510]/95 to-[#050510]/80 backdrop-blur-xl border-t border-white/5 pb-[env(safe-area-inset-bottom,0px)] md:hidden"
>
<div className="flex items-center justify-around h-[50px] px-2 relative">
{/* Главная */}
<Link
href="/settings/brain"
className={cn(
"flex flex-col items-center justify-center p-2 rounded-xl transition-all active:scale-90",
isActive('/settings/brain')
? "text-indigo-400 bg-indigo-500/5 shadow-[inset_0_0_10px_rgba(99,102,241,0.05)]"
: "text-slate-500 hover:text-slate-300"
)}
>
<Brain className="w-[22px] h-[22px]" />
</Link>
{/* Чаты */}
<button
onClick={handleChatsClick}
className={cn(
"flex flex-col items-center justify-center p-2 rounded-xl transition-all active:scale-90",
isActive('/chats')
? "text-indigo-400 bg-indigo-500/5 shadow-[inset_0_0_10px_rgba(99,102,241,0.05)]"
: "text-slate-500 hover:text-slate-300"
)}
>
<MessageSquare className="w-[22px] h-[22px]" />
</button>
{/* Записи */}
<Link
href="/appointments"
className={cn(
"flex flex-col items-center justify-center p-2 rounded-xl transition-all active:scale-90",
isActive('/appointments')
? "text-indigo-400 bg-indigo-500/5 shadow-[inset_0_0_10px_rgba(99,102,241,0.05)]"
: "text-slate-500 hover:text-slate-300"
)}
>
<Calendar className="w-[22px] h-[22px]" />
</Link>
{/* Menu */}
<button
onClick={() => document.dispatchEvent(new CustomEvent('toggle-mobile-sidebar'))}
className="flex flex-col items-center justify-center p-2 rounded-xl text-slate-500 active:scale-90 hover:text-slate-300 transition-all"
>
<Menu className="w-[22px] h-[22px]" />
</button>
</div>
</motion.nav>
)}
</AnimatePresence>
)
}