* Refactor CSS Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Refactor about section Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Refactor CSS for experiences section Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Update education section Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Update projects section Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Update publication + accomplishment section Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Update achievements section Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Refactor footer CSS Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Re-use section title adjustment css for top header Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Refactor navbar CSS Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Refactor sidebar CSS Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Use unified navbar for all pages Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Refactor 404 page CSS Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Refactor list page css Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Fix notes page css Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Refactor single page css Signed-off-by: hossainemruz <hossainemruz@gmail.com> * Introduce color variables Signed-off-by: hossainemruz <hossainemruz@gmail.com> --------- Signed-off-by: hossainemruz <hossainemruz@gmail.com>
62 lines
2.2 KiB
JavaScript
62 lines
2.2 KiB
JavaScript
const updateNavBar = () => {
|
|
const topNavbar = document.getElementById('top-navbar')
|
|
const navbarToggler = document.getElementById('navbar-toggler')
|
|
const themeIcon = document.getElementById('navbar-theme-icon-svg')
|
|
|
|
if (window.scrollY > 40) {
|
|
topNavbar?.classList.remove('transparent-navbar')
|
|
topNavbar?.classList.add('shadow')
|
|
|
|
navbarToggler?.classList.remove('navbar-dark')
|
|
navbarToggler?.classList.add('navbar-light')
|
|
|
|
// color theme selector a.k.a. dark mode
|
|
themeIcon?.classList.remove('navbar-icon-svg-dark')
|
|
|
|
// get the main logo from hidden img tag
|
|
const mainLogo = document.getElementById('main-logo')
|
|
if (mainLogo) {
|
|
const logoURL = mainLogo.getAttribute('src')
|
|
document.getElementById('logo')?.setAttribute('src', logoURL)
|
|
}
|
|
} else {
|
|
topNavbar?.classList.remove('shadow')
|
|
topNavbar?.classList.add('transparent-navbar')
|
|
|
|
navbarToggler?.classList.remove('navbar-light')
|
|
navbarToggler?.classList.add('navbar-dark')
|
|
|
|
// color theme selector a.k.a. dark mode
|
|
themeIcon?.classList.add('navbar-icon-svg-dark')
|
|
|
|
// get the inverted logo from hidden img tag
|
|
const invertedLogo = document.getElementById('inverted-logo')
|
|
if (invertedLogo) {
|
|
const logoURL = invertedLogo.getAttribute('src')
|
|
document.getElementById('logo')?.setAttribute('src', logoURL)
|
|
}
|
|
}
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
// change navbar style on scroll
|
|
// ==================================================
|
|
// When the user scrolls down 80px from the top of the document,
|
|
// resize the navbar's padding and the logo's font size
|
|
const topNavbar = document.getElementById('top-navbar')
|
|
if (topNavbar?.classList.contains('homepage')) {
|
|
document.addEventListener('scroll', updateNavBar)
|
|
updateNavBar()
|
|
}
|
|
|
|
// Creates a click handler to collapse the navigation when
|
|
// anchors in the mobile nav pop up are clicked
|
|
const navMain = document.getElementsByClassName('navbar-collapse')
|
|
Array.from(navMain).forEach(function (el) {
|
|
el.addEventListener('click', function (e) {
|
|
if (e.target.tagName === 'A') {
|
|
el.classList.add('collapse')
|
|
}
|
|
})
|
|
})
|
|
})
|