Skip to content

Commit

Permalink
Merge pull request #1187 from Raman-Maurya/main
Browse files Browse the repository at this point in the history
Day/night icon issue solved.
  • Loading branch information
Apoorva57 authored Nov 9, 2024
2 parents 1bf0b1e + 0cbc4ec commit a84cae0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/Navbar/Navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<div class="theme-switcher">
<input type="checkbox" id="theme-toggle" />
<label for="theme-toggle" class="switch"></label>
<img id="photo" src="/images/initialpng.png" alt="change mode" style="height: 40px; margin-left: 10px;">
</div>
</nav>
</header>
Expand Down
7 changes: 7 additions & 0 deletions components/Navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@ const toggleDarkMode = () => {
const body = document.body;
body.classList.toggle('darkmode');

//setting photopaths for the images
const photoPaths = ["/images/sun.png", "/images/moon.png"];
const photoElement = document.getElementById("photo");

// Update the theme preference in local storage
if (body.classList.contains('darkmode')) {
icon.checked = true; // Set checkbox to checked
localStorage.setItem('theme', 'dark');
photoElement.src = photoPaths[1]; //set moon for night mode

} else {
icon.checked = false; // Set checkbox to unchecked
localStorage.setItem('theme', 'light');
photoElement.src = photoPaths[0]; //set sun for day
}
};

Expand Down
Binary file added images/initialpng.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/sun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a84cae0

Please sign in to comment.