From a3d4f2b11c6ba1ab8f9ff8883fc346f20e3aef65 Mon Sep 17 00:00:00 2001 From: asif Date: Mon, 23 Dec 2024 17:36:42 +0530 Subject: [PATCH] added animation to submenu --- src/components/MenuBar.jsx | 74 ++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/src/components/MenuBar.jsx b/src/components/MenuBar.jsx index 06b385b..f2959d3 100644 --- a/src/components/MenuBar.jsx +++ b/src/components/MenuBar.jsx @@ -3,35 +3,49 @@ import PropTypes from "prop-types"; import { useTranslation } from "react-i18next"; import clsx from "clsx"; import { useState } from "react"; +import { AnimatePresence, motion } from "motion/react"; function SubMenu({ items, isVisible, onLinkClick }) { const { t } = useTranslation(); return ( -
- {items.map((subItem, index) => ( -
- {t(subItem.name)} + + {isVisible && ( +
+ + {items.map((subItem, index) => ( +
+ {t(subItem.name)} +
+ ))} +
+ + +
- ))} - - - -
+ )} + ); } @@ -41,14 +55,20 @@ function MenuBar({ menuItems }) { return (
{menuItems.map((item, index) => ( -
setActiveMenu(index)} onMouseLeave={() => setActiveMenu(null)} > {t(item.name)} - {item.submenu.length > 0 && setActiveMenu(null)}/>} + {item.submenu.length > 0 && ( + setActiveMenu(null)} + /> + )}
))}