Skip to content

Commit

Permalink
Merge pull request #371 from sezallagwal/fix/DarkModeFooter
Browse files Browse the repository at this point in the history
fixed dark mode toggle for footer section
  • Loading branch information
Rizwan102003 authored Oct 24, 2024
2 parents a560760 + ac24b46 commit 73be2d6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
15 changes: 15 additions & 0 deletions darkmode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ let darkmode = localStorage.getItem("darkmode");
const themeToggleBtn = document.getElementById("theme-toggle");
const themeIcon = document.getElementById("theme-toggle-icon");
const body = document.body;
const footer = document.querySelector("footer"); // Select the footer element
const footerSpan = footer.querySelector(".website-name"); // Select the span inside the footer
const footerParagraph = footer.querySelector(".footer-about-text");

// Enable Dark Mode
const enableDarkMode = () => {
body.classList.add("dark-mode");
body.classList.remove("light-mode"); // Ensure light mode class is removed
footer.classList.add("dark-mode-footer"); // Add dark mode class to footer
footer.classList.remove("light-mode-footer");
footerSpan.classList.add("dark-text");
footerSpan.classList.remove("light-text");
footerParagraph.classList.add("dark-text");
footerParagraph.classList.remove("light-text");
localStorage.setItem("darkmode", "active");
themeIcon.src = "images/light-mode.png"; // Light mode icon in dark mode
};
Expand All @@ -16,6 +25,12 @@ const enableDarkMode = () => {
const disableDarkMode = () => {
body.classList.remove("dark-mode");
body.classList.add("light-mode"); // Ensure light mode class is added
footer.classList.remove("dark-mode-footer"); // Remove dark mode class from footer
footer.classList.add("light-mode-footer");
footerSpan.classList.add("light-text");
footerSpan.classList.remove("dark-text");
footerParagraph.classList.add("light-text");
footerParagraph.classList.remove("dark-text");
localStorage.setItem("darkmode", "inactive");
themeIcon.src = "images/dark-mode.png"; // Dark mode icon in light mode
};
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ <h3>Add Event</h3>
<div class="calendar-grid" id="calendar-grid"></div>
</div>
</section>

<hr>
<footer class="footer-section">
<div class="container">
<!-- Logo and About Section -->
Expand Down
22 changes: 20 additions & 2 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,26 @@ body.dark-mode #theme-switch {
color: #6b7280;
font-family: 'Arial', sans-serif;
}

/* Light Mode Footer */
.light-mode-footer {
background-color: #f8f9fa;
color: #000;
}

/* Dark Mode Footer */
.dark-mode-footer {
background-color: #2E2E2E;
color: #fff;
}

.dark-text {
color: #f1f1f1;
}

.light-text {
color: black;
}

.container {
max-width: 1200px;
Expand Down Expand Up @@ -937,13 +957,11 @@ body.dark-mode #theme-switch {
.website-name {
font-size: 1.5rem;
font-weight: bold;
color: #111827;
}

.footer-about-text {
margin-top: 15px;
line-height: 1.6;
color: #000;
font-style: italic;
}

Expand Down

0 comments on commit 73be2d6

Please sign in to comment.