diff --git a/src/utils/config.js b/src/utils/config.js index e97d368..25c448e 100644 --- a/src/utils/config.js +++ b/src/utils/config.js @@ -1,9 +1,9 @@ -export const bindEvents = () => { +export const bindConfig = () => { document.querySelectorAll('a[data-click]').forEach((e) => { e.addEventListener('click', (evt) => { evt.preventDefault(); const dialog = document.querySelector('dialog.'+e.getAttribute('data-click')); - document.querySelector('#menu-toggle').checked = false; + document.getElementById('menu-toggle').checked = false; dialog?.classList.remove('hidden'); dialog?.showModal(); dialog?.addEventListener('click', (evt) => { @@ -15,3 +15,12 @@ export const bindEvents = () => { }); }); }; + +export const bindMenu = () => { + const menu = document.getElementById('nav-menu'); + window.addEventListener('click', (evt) => { + if (!evt.composedPath().includes(menu)) { + document.getElementById('menu-toggle').checked = false; + } + }); +}; \ No newline at end of file