From e248c463c941cb8f77c84f507a785280f6111fe3 Mon Sep 17 00:00:00 2001 From: bagusajisaputroo Date: Wed, 23 Apr 2025 10:59:15 +0700 Subject: [PATCH] changing color role and username in navbar while scroll --- src/layouts/demo2/header/HeaderTopbar.tsx | 85 +++++++++++++---------- 1 file changed, 50 insertions(+), 35 deletions(-) diff --git a/src/layouts/demo2/header/HeaderTopbar.tsx b/src/layouts/demo2/header/HeaderTopbar.tsx index 485311c..5256605 100644 --- a/src/layouts/demo2/header/HeaderTopbar.tsx +++ b/src/layouts/demo2/header/HeaderTopbar.tsx @@ -10,48 +10,63 @@ const HeaderTopbar = () => { const itemChatRef = useRef(null); const itemUserRef = useRef(null); const itemNotificationsRef = useRef(null); + const { isRTL } = useLanguage(); + const [isSticky, setIsSticky] = useState(false); + useEffect(() => { + const handleScroll = () => { + setIsSticky(window.scrollY > 100); + }; + window.addEventListener('scroll', handleScroll); + return () => window.removeEventListener('scroll', handleScroll); + }, []); + const handleDropdownChatShow = () => { window.dispatchEvent(new Event('resize')); }; - // console.log(getAuth()) + return ( -
-
- {getAuth()?.user.username} - {getAuth()?.role_name} -
- - - - - User avatar - - {DropdownUser({ menuItemRef: itemUserRef })} - - -
+
+
+ + {getAuth()?.user.username} + + + {getAuth()?.role_name} + +
+ + + + User avatar + + {DropdownUser({ menuItemRef: itemUserRef })} + + +
); };