Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 66 additions & 32 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useEffect, useRef, useState } from 'react'
import { BiDonateBlood } from 'react-icons/bi'
import { Link, useLocation } from 'react-router-dom'
import ContainerWrapper from './ContainerWrapper'
import { motion, AnimatePresence } from 'framer-motion'

interface NavItem {
label: string
Expand Down Expand Up @@ -147,6 +148,31 @@ export default function Navbar() {
setActiveDropdown(activeDropdown === label ? null : label)
}

// Animation variants for dropdown
const dropdownVariants = {
hidden: {
opacity: 0,
height: 0,
overflow: 'hidden'
},
visible: {
opacity: 1,
height: 'auto',
transition: {
duration: 0.3,
ease: "easeInOut"
}
},
exit: {
opacity: 0,
height: 0,
transition: {
duration: 0.2,
ease: "easeInOut"
}
}
}

return (
<nav
className={`sticky top-0 z-50 bg-white transition-all duration-200 ${
Expand Down Expand Up @@ -323,40 +349,48 @@ export default function Navbar() {
/>
</button>

{/* Mobile dropdown menu */}
{activeDropdown === item.label && (
<div className="mt-1 rounded-lg bg-gray-50/50">
{item.children.map((child) => (
<Link
key={child.label}
to={child.path}
target={child.isExternal ? '_blank' : undefined}
rel={child.isExternal ? 'noopener noreferrer' : undefined}
onClick={() => setIsMenuOpen(false)}
className="flex items-center px-4 py-3 pr-12 text-gray-700 transition rounded-md hover:bg-gray-100"
>
{child.icon && (
<span className="ml-3 text-gray-500">{child.icon}</span>
)}
<div>
<div className="flex items-center">
{child.label}
{child.badge && (
<span className="px-1.5 py-0.5 mr-1.5 text-xs font-medium text-white bg-green-500 rounded-full">
{child.badge}
</span>

<AnimatePresence>
{activeDropdown === item.label && (
<motion.div
className="mt-1 rounded-lg bg-gray-50/50 overflow-hidden"
variants={dropdownVariants}
initial="hidden"
animate="visible"
exit="exit"
>
{item.children.map((child) => (
<Link
key={child.label}
to={child.path}
target={child.isExternal ? '_blank' : undefined}
rel={child.isExternal ? 'noopener noreferrer' : undefined}
onClick={() => setIsMenuOpen(false)}
className="flex items-center px-4 py-3 pr-12 text-gray-700 transition rounded-md hover:bg-gray-100"
>
{child.icon && (
<span className="ml-3 text-gray-500">{child.icon}</span>
)}
<div>
<div className="flex items-center">
{child.label}
{child.badge && (
<span className="px-1.5 py-0.5 mr-1.5 text-xs font-medium text-white bg-green-500 rounded-full">
{child.badge}
</span>
)}
</div>
{child.description && (
<p className="text-xs text-gray-500">
{child.description}
</p>
)}
</div>
{child.description && (
<p className="text-xs text-gray-500">
{child.description}
</p>
)}
</div>
</Link>
))}
</div>
)}
</Link>
))}
</motion.div>
)}
</AnimatePresence>
</>
) : (
<Link
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Donate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export default function Donate() {
{/* Additional Info Card */}
<div className="p-5 mt-8 border border-blue-100 rounded-xl bg-blue-50">
<div className="flex">
<div className="flex items-center justify-center w-10 h-10 ml-3 bg-blue-100 rounded-full">
<div className="flex items-center justify-center w-10 h-10 ml-3 bg-blue-100 rounded-full shrink-0">
<svg
className="w-5 h-5 text-blue-600"
fill="currentColor"
Expand Down