-
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.
Add theme persistence and responsive styles
Implemented theme persistence using session storage for theme switching. Updated CSS for better alignment and smoother transitions on different screen sizes. Integrated Bootstrap, jQuery libraries, and cleaned redundant inline styles in index.html.
- Loading branch information
1 parent
d27ed97
commit 040d274
Showing
5 changed files
with
117 additions
and
52 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,17 @@ | ||
document.getElementById('theme-switcher').addEventListener('click', function () { | ||
// Function to toggle the theme and save it to session storage | ||
const toggleTheme = () => { | ||
const body = document.body; | ||
const currentTheme = body.getAttribute('data-bs-theme'); | ||
const newTheme = currentTheme === 'light' ? 'dark' : 'light'; | ||
body.setAttribute('data-bs-theme', newTheme); | ||
sessionStorage.setItem('theme', newTheme); | ||
}; | ||
|
||
// Add event listener to the theme switcher button | ||
document.getElementById('theme-switcher').addEventListener('click', toggleTheme); | ||
|
||
// Check session storage for saved theme on page load | ||
window.addEventListener('DOMContentLoaded', () => { | ||
const savedTheme = sessionStorage.getItem('theme') || 'light'; | ||
document.body.setAttribute('data-bs-theme', savedTheme); | ||
}); |
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