Skip to content

Commit

Permalink
add function to toggle menu when button is present
Browse files Browse the repository at this point in the history
  • Loading branch information
HectorVilas committed Apr 29, 2023
1 parent b3967d4 commit 008d723
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion modules/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@ export function goToPage(page) {

main.replaceChildren(...sections);
window.scrollTo(0, 0);
}
}

export function toggleNav() {
const nav = document.querySelector('#navigation');
nav.classList.toggle('nav-show');
}
4 changes: 3 additions & 1 deletion modules/header.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { goToPage } from "./functions.js";
import { goToPage, toggleNav } from "./functions.js";

const svgNs = 'http://www.w3.org/2000/svg';

Expand All @@ -13,6 +13,8 @@ export default function header() {
menuBtn,
nav(),
);

menuBtn.addEventListener('click', toggleNav);

return header;
}
Expand Down

0 comments on commit 008d723

Please sign in to comment.