diff --git a/src/utils/config.js b/src/utils/config.js new file mode 100644 index 0000000..e97d368 --- /dev/null +++ b/src/utils/config.js @@ -0,0 +1,17 @@ +export const bindEvents = () => { + 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; + dialog?.classList.remove('hidden'); + dialog?.showModal(); + dialog?.addEventListener('click', (evt) => { + if (evt.target === dialog) { + dialog?.close(); + dialog?.classList.add('hidden'); + } + }); + }); + }); +};