-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhaul website styling and interactivity
- Loading branch information
Showing
7 changed files
with
484 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
document.addEventListener('DOMContentLoaded', function() { | ||
const mobileNavToggle = document.querySelector('.mobile-nav-toggle'); | ||
const mobileMenu = document.querySelector('.mobile-menu'); | ||
const toggleSpans = mobileNavToggle.querySelectorAll('span'); | ||
|
||
mobileNavToggle.addEventListener('click', function() { | ||
mobileMenu.classList.toggle('active'); | ||
|
||
// Animate hamburger to X | ||
toggleSpans[0].style.transform = mobileMenu.classList.contains('active') | ||
? 'rotate(45deg) translate(5px, 6px)' | ||
: 'none'; | ||
toggleSpans[1].style.opacity = mobileMenu.classList.contains('active') | ||
? '0' | ||
: '1'; | ||
toggleSpans[2].style.transform = mobileMenu.classList.contains('active') | ||
? 'rotate(-45deg) translate(5px, -6px)' | ||
: 'none'; | ||
}); | ||
|
||
// Close menu when clicking outside | ||
document.addEventListener('click', function(event) { | ||
if (!mobileMenu.contains(event.target) && | ||
!mobileNavToggle.contains(event.target) && | ||
mobileMenu.classList.contains('active')) { | ||
mobileMenu.classList.remove('active'); | ||
toggleSpans[0].style.transform = 'none'; | ||
toggleSpans[1].style.opacity = '1'; | ||
toggleSpans[2].style.transform = 'none'; | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
function initializeTheme() { | ||
// Check for saved theme preference or default to dark | ||
const savedTheme = localStorage.getItem('theme') || 'dark'; | ||
document.documentElement.setAttribute('data-theme', savedTheme); | ||
|
||
// Create and append the toggle button | ||
const toggleButton = document.createElement('button'); | ||
toggleButton.className = 'theme-toggle'; | ||
|
||
// Use more reliable Unicode characters with fallback | ||
const sunIcon = '☀️'; | ||
const moonIcon = '🌙'; | ||
|
||
// Set initial button text with fallback | ||
function updateButtonText(theme) { | ||
if (theme === 'dark') { | ||
toggleButton.innerHTML = `${sunIcon} <span>Light</span>`; | ||
} else { | ||
toggleButton.innerHTML = `${moonIcon} <span>Dark</span>`; | ||
} | ||
} | ||
|
||
updateButtonText(savedTheme); | ||
|
||
toggleButton.addEventListener('click', () => { | ||
const currentTheme = document.documentElement.getAttribute('data-theme'); | ||
const newTheme = currentTheme === 'dark' ? 'light' : 'dark'; | ||
|
||
document.documentElement.setAttribute('data-theme', newTheme); | ||
localStorage.setItem('theme', newTheme); | ||
updateButtonText(newTheme); | ||
}); | ||
|
||
document.body.appendChild(toggleButton); | ||
} | ||
|
||
// Initialize theme when DOM is loaded | ||
document.addEventListener('DOMContentLoaded', initializeTheme); |
Oops, something went wrong.