From 0fd0b16b4cb4b5287580b85575a354dbea707e86 Mon Sep 17 00:00:00 2001 From: William Brawner Date: Tue, 9 Jul 2024 17:27:04 -0600 Subject: [PATCH] Improve sidebar handling when JavaScript is enabled --- web/src/main/resources/static/js/index.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/web/src/main/resources/static/js/index.js b/web/src/main/resources/static/js/index.js index 1b5c89f..2e33813 100644 --- a/web/src/main/resources/static/js/index.js +++ b/web/src/main/resources/static/js/index.js @@ -5,4 +5,19 @@ for (let i = 0; i < forms.length; i++) { form.onsubmit = () => { form.querySelector('input[type="submit"]').disabled = true } -} \ No newline at end of file +} + +const sidebar = document.querySelector('#sidebar') + +document.querySelector('#hamburger').onclick = (e) => { + e.preventDefault() + sidebar.style.transform = 'translateX(0)' +} + +document.addEventListener('click', (e) => { + const style = window.getComputedStyle(sidebar) + const matrix = new DOMMatrixReadOnly(style.getPropertyValue("transform")) + if (matrix.m41 === 0) { + sidebar.style.transform = 'translateX(-100%)' + } +}) \ No newline at end of file