Skip to content

Commit

Permalink
feat: menu and leftNav close when user change page
Browse files Browse the repository at this point in the history
  • Loading branch information
12Gustavo21 committed Mar 4, 2024
1 parent a283b9f commit c472311
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
20 changes: 14 additions & 6 deletions src/assets/components/leftNav/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import React from "react";

//Styles
import { Link } from "react-router-dom";
import * as S from "./style";

//React Router Dom
import { Link } from "react-router-dom";
const LeftNav = ({ open, onClose }) => {
const handleLinkClick = () => {
onClose();
};

const links = document.querySelectorAll("a");

links.forEach((link) => {
link.addEventListener("click", () => {
handleLinkClick();
});
});

const RightNav = ({ open }) => {
return (
<S.List open={open}>
<S.Item>
Expand All @@ -28,4 +36,4 @@ const RightNav = ({ open }) => {
);
};

export default RightNav;
export default LeftNav;
6 changes: 5 additions & 1 deletion src/assets/components/menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ const StyledBurger = styled.section`
const Burger = () => {
const [open, setOpen] = useState(false);

const closeMenu = () => {
setOpen(false);
};

return (
<>
<StyledBurger open={open} onClick={() => setOpen(!open)}>
<section />
<section />
<section />
</StyledBurger>
<LeftNav open={open} />
<LeftNav open={open} onClose={closeMenu} />
</>
);
};
Expand Down

0 comments on commit c472311

Please sign in to comment.