frontend: close navigation dropdown when clicked
close the navigation dropdown if any click is registered anywhere in the DOM. Previously the dropdown was closed only when clicked
This commit is contained in:
@ -26,9 +26,9 @@ This website is packaged as a container and deployed using nginx.
|
|||||||
```bash
|
```bash
|
||||||
source .env
|
source .env
|
||||||
docker build -t my-portfolio-app .
|
docker build -t my-portfolio-app .
|
||||||
docker tag my-portfolio-app:latest ${DOCKER_REGISTRY}/my-portfolio-app:latest
|
docker tag my-portfolio-app:latest $DOCKER_REGISTRY/my-portfolio-app:latest
|
||||||
docker push ${DOCKER_REGISTRY}/my-portfolio-app:latest
|
docker push $DOCKER_REGISTRY/my-portfolio-app:latest
|
||||||
|
|
||||||
# Check the registry
|
# Check the registry
|
||||||
curl -u user:pass https://${DOCKER_REGISTRY}/v2/_catalog
|
curl -u user:pass https://$DOCKER_REGISTRY/v2/_catalog
|
||||||
```
|
```
|
||||||
@ -26,6 +26,19 @@ const Navbar: React.FC<NavProps> = ({ toggleDarkMode, darkMode }) => {
|
|||||||
localStorage.setItem('DARK_MODE', String(darkMode))
|
localStorage.setItem('DARK_MODE', String(darkMode))
|
||||||
}, [darkMode])
|
}, [darkMode])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleClickoutside = (event: MouseEvent) => {
|
||||||
|
if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
|
||||||
|
setIsMenuOpen(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('mousedown', handleClickoutside)
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('mousedown', handleClickoutside)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const menuItem = [
|
const menuItem = [
|
||||||
{ title: 'Home', href: '/' },
|
{ title: 'Home', href: '/' },
|
||||||
{ title: 'Experience', href: '/experience' },
|
{ title: 'Experience', href: '/experience' },
|
||||||
|
|||||||
Reference in New Issue
Block a user