repos / neovimcraft

website that makes it easy to find neovim plugins
git clone https://github.com/neurosnap/neovimcraft.git

neovimcraft / static
Eric Bower · 18 Jan 23

nav.js

 1function must(pattern) {
 2  const el = document.querySelector(pattern);
 3  if (!el) {
 4    throw new Error(`${pattern} not found`);
 5  }
 6  return el;
 7}
 8
 9function mustAll(pattern) {
10  const el = document.querySelectorAll(pattern);
11  if (!el) {
12    throw new Error(`${pattern} not found`);
13  }
14  return el;
15}
16
17function nav() {
18  const menuBtnEl = must("#menu-btn");
19  const menuCloseEl = mustAll(".menu-close");
20  menuBtnEl.addEventListener("click", () => {
21    menu.classList.remove("hidden");
22  });
23  menuCloseEl.forEach((el) => {
24    el.addEventListener("click", () => {
25      menu.classList.add("hidden");
26    });
27  });
28}
29
30document.addEventListener("DOMContentLoaded", nav);