Skip to content

Commit

Permalink
fixed header & nav
Browse files Browse the repository at this point in the history
  • Loading branch information
vinib96 committed Jun 3, 2024
1 parent 37c839f commit 7303dd6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Frontend/src/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function Header() {
</button>
</div>
</div>
<Nav />
<Nav setMenuOpen={setMenuOpen} />
<div className={menuOpen ? 'header__menu_open' : 'header__menu'}>
<Search menuOpen={menuOpen} setMenuOpen={setMenuOpen} />
<Nav menuOpen={menuOpen} setMenuOpen={setMenuOpen} />
Expand Down
40 changes: 29 additions & 11 deletions Frontend/src/components/Nav.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import './Nav.css';
import { Link } from 'react-router-dom';
import { Link, useNavigate } from 'react-router-dom';

function Nav({ menuOpen, setMenuOpen }) {
const navigate = useNavigate();

const handleLinkClick = (path) => {
setMenuOpen(false); // Fecha o menu
navigate(path); // Navega para a nova rota
};

const handleScrollToFooter = () => {
() => setMenuOpen(false);
const footer = document.getElementById('footer');
if (footer) {
footer.scrollIntoView({ behavior: 'smooth' });
} else {
console.error('Footer not found');
}
setMenuOpen(false); // Fecha o menu
setTimeout(() => {
const footer = document.getElementById('footer');
if (footer) {
footer.scrollIntoView({ behavior: 'smooth' });
} else {
console.error('Footer not found');
}
}, 0);
};

return (
Expand All @@ -19,7 +28,10 @@ function Nav({ menuOpen, setMenuOpen }) {
<Link
className='nav__link'
to='/store'
onClick={() => setMenuOpen(false)}
onClick={(e) => {
e.preventDefault();
handleLinkClick('/store');
}}
>
LOJA
</Link>
Expand All @@ -28,7 +40,10 @@ function Nav({ menuOpen, setMenuOpen }) {
<Link
className='nav__link'
to='/sobre'
onClick={() => setMenuOpen(false)}
onClick={(e) => {
e.preventDefault();
handleLinkClick('/sobre');
}}
>
SOBRE
</Link>
Expand All @@ -37,7 +52,10 @@ function Nav({ menuOpen, setMenuOpen }) {
<Link
className='nav__link'
to='/maps'
onClick={() => setMenuOpen(false)}
onClick={(e) => {
e.preventDefault();
handleLinkClick('/maps');
}}
>
PONTOS DE COLETA
</Link>
Expand Down

0 comments on commit 7303dd6

Please sign in to comment.