Skip to content

Commit

Permalink
Merge pull request #325 from soniya-malviy/index.html
Browse files Browse the repository at this point in the history
Added dark mode functionality
  • Loading branch information
Rajan-Barnwal authored Jun 14, 2024
2 parents 3d382ce + 62cb784 commit 1ed2d18
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 21 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
<li><a href="pricing.html" class="hover-link">Pricing</a></li>
<li><a href="resources.html" class="hover-link">Resources</a></li>
<li>
<a href="signin.html" class="btn hover-link text-light"
>Sign in</a
<a href="signin.html" class="hover-link"
>SignIn</a
>
</li>
<li>
<a href="signup.html" class="btn hover-link text-light"
>Sign up</a
<a href="signup.html" class="hover-link"
>SignUp</a
>
</li>
<img src="moon.png" id="icon" />
Expand Down Expand Up @@ -355,23 +355,25 @@ <h4>Resources</h4>
></script>

<script>
const toggleButton = document.getElementById("nav-toggle");
const navLinks = document.getElementById("nav-links");
document.addEventListener("DOMContentLoaded", () => {
const toggleButton = document.getElementById("nav-toggle");
const navLinks = document.getElementById("nav-links");
const icon = document.getElementById("icon");

toggleButton.addEventListener("click", () => {
navLinks.classList.toggle("active");
});

var icon = document.getElementById("icon");
toggleButton.addEventListener("click", () => {
navLinks.classList.toggle("active");
});

icon.onclick = function () {
document.body.classList.toggle("dark-theme");
if (document.body.classList.contains("dark-theme")) {
icon.src = "sun.png";
} else {
icon.src = "moon.png";
}
};
icon.addEventListener("click", () => {
document.body.classList.toggle("dark-theme");
if (document.body.classList.contains("dark-theme")) {
icon.src = "sun.png";
} else {
icon.src = "moon.png";
}
});
});
</script>

</body>
</html>
8 changes: 8 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -654,3 +654,11 @@ button {
background: linear-gradient(270deg, #e4f1ff, #cce5ff);
color: var(--accent-color);
}

#nav-links.active {
display: block;
}
.dark-theme {
background-color: #333;
color: #fff;
}

0 comments on commit 1ed2d18

Please sign in to comment.