diff --git a/src/js/vocabulary.js b/src/js/vocabulary.js index 2f32af68..4617dd68 100644 --- a/src/js/vocabulary.js +++ b/src/js/vocabulary.js @@ -1,37 +1,43 @@ const exploreButton = document.querySelector('button.explore'); const explorePanel = document.querySelector('.explore-panel'); -// explorePanel.classList.add('hide'); -if(exploreButton!==null && explorePanel!==null) { - exploreButton.addEventListener('click', (event) => { - explorePanel.classList.toggle('expand'); - // explorePanel.classList.toggle('hide'); - }); -} - +exploreButton.addEventListener('click', (event) => { + explorePanel.classList.toggle('expand'); + // Toggle button text between 'View' and 'Close' + if (explorePanel.classList.contains('expand')) { + exploreButton.textContent = 'Close'; + } else { + exploreButton.textContent = 'View'; + } +}); const menuButton = document.querySelector('button.expand-menu'); const menuPanel = document.querySelector('.primary-menu'); -if(menuButton !== null && menuPanel !== null) { - menuButton.addEventListener('click', (event) => { - menuPanel.classList.toggle('expand'); - // explorePanel.classList.toggle('hide'); - }); -} - +menuButton.addEventListener('click', (event) => { + menuPanel.classList.toggle('expand'); + // Toggle button text between 'View' and 'Close' + if (menuPanel.classList.contains('expand')) { + menuButton.textContent = 'Close'; + } else { + menuButton.textContent = 'View'; + } +}); const attributionButton = document.querySelector('button.expand-attribution'); const attributionPanel = document.querySelector('.attribution-panel'); -if (attributionButton !== null && attributionPanel !== null ) { - +if (attributionButton !== null && attributionPanel !== null) { attributionButton.addEventListener('click', (event) => { - attributionButton.classList.toggle('selected'); attributionPanel.classList.toggle('expand'); - // explorePanel.classList.toggle('hide'); - }); -} + // Toggle button text between 'View' and 'Close' + if (attributionPanel.classList.contains('expand')) { + attributionButton.textContent = 'Close'; + } else { + attributionButton.textContent = 'View'; + } + }); +} \ No newline at end of file