header updated
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import { Box, Flex, Image, VStack, Text, Link } from '@chakra-ui/react';
|
import { Box, Flex, Image, VStack, Text, Link } from '@chakra-ui/react';
|
||||||
import { GiHamburgerMenu } from "react-icons/gi";
|
import { GiHamburgerMenu } from "react-icons/gi";
|
||||||
|
import { IoCloseSharp } from "react-icons/io5";
|
||||||
import { colors } from '../colors';
|
import { colors } from '../colors';
|
||||||
import { useState, useRef, useLayoutEffect } from 'react';
|
import { useState, useRef, useLayoutEffect } from 'react';
|
||||||
import {
|
import {
|
||||||
DrawerBody,
|
DrawerBody,
|
||||||
DrawerCloseTrigger,
|
|
||||||
DrawerContent,
|
DrawerContent,
|
||||||
DrawerRoot,
|
DrawerRoot,
|
||||||
} from '@/components/ui/drawer';
|
} from '@/components/ui/drawer';
|
||||||
@@ -19,9 +19,32 @@ function Header({ showMenu = false }: HeaderProps) {
|
|||||||
const headerRef = useRef<HTMLDivElement>(null);
|
const headerRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (headerRef.current) {
|
const updateHeight = () => {
|
||||||
setHeaderHeight(headerRef.current.offsetHeight);
|
if (headerRef.current) {
|
||||||
|
setHeaderHeight(headerRef.current.getBoundingClientRect().height);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
updateHeight();
|
||||||
|
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
window.addEventListener('resize', updateHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const observer = typeof ResizeObserver !== 'undefined' && headerRef.current
|
||||||
|
? new ResizeObserver(updateHeight)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
if (observer && headerRef.current) {
|
||||||
|
observer.observe(headerRef.current);
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
window.removeEventListener('resize', updateHeight);
|
||||||
|
}
|
||||||
|
observer?.disconnect();
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
@@ -51,14 +74,22 @@ function Header({ showMenu = false }: HeaderProps) {
|
|||||||
top="50%"
|
top="50%"
|
||||||
transform="translateY(-50%)"
|
transform="translateY(-50%)"
|
||||||
cursor="pointer"
|
cursor="pointer"
|
||||||
onClick={() => setIsDrawerOpen(true)}
|
onClick={() => setIsDrawerOpen((prev) => !prev)}
|
||||||
_hover={{ opacity: 0.8 }}
|
_hover={{ opacity: 0.8 }}
|
||||||
>
|
>
|
||||||
<GiHamburgerMenu
|
{isDrawerOpen ? (
|
||||||
size={40}
|
<IoCloseSharp
|
||||||
color="#2E683D"
|
size={40}
|
||||||
style={{ display: 'block' }}
|
color="#2E683D"
|
||||||
/>
|
style={{ display: 'block' }}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<GiHamburgerMenu
|
||||||
|
size={40}
|
||||||
|
color="#2E683D"
|
||||||
|
style={{ display: 'block' }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
@@ -73,16 +104,14 @@ function Header({ showMenu = false }: HeaderProps) {
|
|||||||
padding={0}
|
padding={0}
|
||||||
positionerProps={{
|
positionerProps={{
|
||||||
style: {
|
style: {
|
||||||
top: `${headerHeight}px`,
|
top: headerHeight ? `${headerHeight}px` : undefined,
|
||||||
right: 0,
|
right: 0,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
height: `calc(100vh - ${headerHeight}px)`
|
height: headerHeight ? `calc(100vh - ${headerHeight}px)` : '100vh',
|
||||||
},
|
},
|
||||||
zIndex: 1100,
|
zIndex: 900,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
||||||
<DrawerCloseTrigger />
|
|
||||||
<DrawerBody
|
<DrawerBody
|
||||||
padding={0}
|
padding={0}
|
||||||
margin={0}
|
margin={0}
|
||||||
|
|||||||
Reference in New Issue
Block a user