From d0271fcae88ceb10890d55f9a99424a174a93918 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 25 Oct 2021 16:28:36 +0200 Subject: chore: hide the about project button on homepage --- htdocs/src/js/app.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'htdocs/src/js') diff --git a/htdocs/src/js/app.js b/htdocs/src/js/app.js index 636eb20..4260079 100644 --- a/htdocs/src/js/app.js +++ b/htdocs/src/js/app.js @@ -83,6 +83,20 @@ function listenMenuBtn() { menuBtn.addEventListener('click', toggleHeaderFooter); } +/** + * Show or hide the project details button depending on current location. + */ +function toggleProjectDetailsBtn() { + const button = document.querySelector('.btn--details'); + const currentPath = window.location.pathname; + + if (currentPath === '/') { + button.style.display = 'none'; + } else { + button.style.display = ''; + } +} + /** * Update the visibility of some DOM elements depending on viewport. */ @@ -105,6 +119,8 @@ function updateView() { details?.classList.remove('hide'); details?.classList.add('fade-in'); } + + toggleProjectDetailsBtn(); } /** @@ -272,6 +288,7 @@ function getProjectsNavItem(id, name) { link.addEventListener('click', (e) => { e.preventDefault(); showProject(id, e.target.href); + toggleProjectDetailsBtn(); if (isSmallVw()) toggleHeaderFooter(); }); item.classList.add('nav__item'); -- cgit v1.2.3