Skip to content

Commit

Permalink
style: format codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 4, 2024
1 parent c0b7873 commit 99e427a
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions Website/app/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,28 @@ function MobileNav({ open }) {
);
}




export default function Header({ props }) {
const [open, setOpen] = useState(false);
const [hcolor, setHcolor] = useState(props + " pt-7");
const onScroll = useCallback(() => {
const { scrollY } = window;
if (window.innerWidth <= 760 && open) {
setOpen(false);
}
if (window.innerWidth > 760) {
if (scrollY === 0) setHcolor(props + " pt-7");
else setHcolor("bg-var shadow-lg pt-4");
}
}, [props, open]);
const onScroll = useCallback(() => {
const { scrollY } = window;
if (window.innerWidth <= 760 && open) {
setOpen(false);
}
if (window.innerWidth > 760) {
if (scrollY === 0) setHcolor(props + " pt-7");
else setHcolor("bg-var shadow-lg pt-4");
}
}, [props, open]);

useEffect(() => {
// add event listener to window
window.addEventListener("scroll", onScroll, { passive: true });
// remove event listener on unmount to prevent memory leaks
return () => {
window.removeEventListener("scroll", onScroll);
};
}, [onScroll]);
useEffect(() => {
// add event listener to window
window.addEventListener("scroll", onScroll, { passive: true });
// remove event listener on unmount to prevent memory leaks
return () => {
window.removeEventListener("scroll", onScroll);
};
}, [onScroll]);

return (
<header
Expand Down

0 comments on commit 99e427a

Please sign in to comment.