From 4fe25f0727c6df2f23d092a92c38ffaf428359cf Mon Sep 17 00:00:00 2001 From: Chunxian Zhang <1836891291@qq.com> Date: Mon, 25 Jul 2022 01:28:29 +0800 Subject: [PATCH] =?UTF-8?q?fe-26=20=E7=BD=91=E9=A1=B5=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lazy-timer-fe/src/components/Navbar.jsx | 90 +++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 lazy-timer-fe/src/components/Navbar.jsx diff --git a/lazy-timer-fe/src/components/Navbar.jsx b/lazy-timer-fe/src/components/Navbar.jsx new file mode 100644 index 0000000..1e23d14 --- /dev/null +++ b/lazy-timer-fe/src/components/Navbar.jsx @@ -0,0 +1,90 @@ +import React, { useEffect } from 'react'; +import { AiOutlineMenu } from 'react-icons/ai'; +import { FiShoppingCart } from 'react-icons/fi'; +import { BsChatLeft } from 'react-icons/bs'; +import { RiNotification3Line } from 'react-icons/ri'; +import { MdKeyboardArrowDown } from 'react-icons/md'; +import { TooltipComponent } from '@syncfusion/ej2-react-popups'; + +import avatar from '../data/avatar.jpg'; +import { Cart, Chat, Notification, UserProfile } from '.'; +import { useStateContext } from '../contexts/ContextProvider'; + +const NavButton = ({ title, customFunc, icon, color, dotColor }) => ( + + + +); + +const Navbar = () => { + const { currentColor, activeMenu, setActiveMenu, handleClick, isClicked, setScreenSize, screenSize } = useStateContext(); + + useEffect(() => { + const handleResize = () => setScreenSize(window.innerWidth); + + window.addEventListener('resize', handleResize); + + handleResize(); + + return () => window.removeEventListener('resize', handleResize); + }, []); + + useEffect(() => { + if (screenSize <= 900) { + setActiveMenu(false); + } else { + setActiveMenu(true); + } + }, [screenSize]); + + const handleActiveMenu = () => setActiveMenu(!activeMenu); + + return ( +
+ + } /> +
+ handleClick('cart')} color={currentColor} icon={} /> + handleClick('chat')} color={currentColor} icon={} /> + handleClick('notification')} color={currentColor} icon={} /> + +
handleClick('userProfile')} + > + user-profile +

+ Hi,{' '} + + Michael + +

+ +
+
+ + {isClicked.cart && ()} + {isClicked.chat && ()} + {isClicked.notification && ()} + {isClicked.userProfile && ()} +
+
+ ); +}; + +export default Navbar;