From a0c0d10faef7622bbfafebbf0b3a5f148a95d612 Mon Sep 17 00:00:00 2001 From: Michael Novotny Date: Thu, 11 May 2023 12:53:04 -0700 Subject: [PATCH] Changes mobile menu animation to be consistent with cart animation. (#1015) --- components/layout/navbar/mobile-menu.tsx | 110 +++++++++++++---------- 1 file changed, 65 insertions(+), 45 deletions(-) diff --git a/components/layout/navbar/mobile-menu.tsx b/components/layout/navbar/mobile-menu.tsx index c960d5218..a12759c89 100644 --- a/components/layout/navbar/mobile-menu.tsx +++ b/components/layout/navbar/mobile-menu.tsx @@ -1,7 +1,7 @@ 'use client'; import { Dialog } from '@headlessui/react'; -import { motion } from 'framer-motion'; +import { AnimatePresence, motion } from 'framer-motion'; import Link from 'next/link'; import { usePathname, useSearchParams } from 'next/navigation'; import { useEffect, useState } from 'react'; @@ -42,57 +42,77 @@ export default function MobileMenu({ menu }: { menu: Menu[] }) { > - { - setMobileMenuIsOpen(false); - }} - className="relative z-50" - > -
- + {mobileMenuIsOpen && ( + { + setMobileMenuIsOpen(false); }} - className="flex w-full flex-col bg-white pb-6 dark:bg-black" + className="relative z-50" > -
- +
+ -
- -
- {menu.length ? ( -
    - {menu.map((item: Menu) => ( -
  • - { - setMobileMenuIsOpen(false); - }} - > - {item.title} - -
  • - ))} -
- ) : null} +
+ +
+ {menu.length ? ( +
    + {menu.map((item: Menu) => ( +
  • + { + setMobileMenuIsOpen(false); + }} + > + {item.title} + +
  • + ))} +
+ ) : null} +
+
-
-
-
+ + )} + ); }