Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added dark mode switch on homepage #136

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/asset 43.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 assets/asset 44.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 assets/asset 45.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
>Doubt Engine</a
>
</li>
<li>
<img src="./assets/asset 43.png" id="mode-switch-icon" />
</li>
</ul>
</div>
<div class="hamburger">
Expand Down Expand Up @@ -559,5 +562,6 @@ <h3>
}
</script>
<script src="scroll-reveal.js"></script>
<script src="mode-switch.js"></script>
</body>
</html>
44 changes: 44 additions & 0 deletions mode-switch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
var icon = document.getElementById("mode-switch-icon");

icon.onclick = function () {
var footer = document.querySelector("footer");
var tables = document.querySelectorAll(".wrapper .table");
var linksTitle = document.querySelectorAll(".links-title");
var copyright = document.querySelector(".copyright");
var copyrightH3 = document.querySelector(".copyright h3");
var navbarLogo = document.querySelector("navbar img"); // assuming the img is directly under navbar

document.body.classList.toggle("dark-mode");
document.documentElement.style.setProperty("--primary-text-color", "#ffffff");
document.documentElement.style.setProperty("--secondary-text-color", "#ffffff");

if (document.body.classList.contains("dark-mode")) {
document.body.style.backgroundColor = "#111111";
document.documentElement.style.setProperty("--primary-text-color", "#ffffff");
document.documentElement.style.setProperty("--secondary-text-color", "#ffffff");
footer.style.backgroundColor = "#242525";
tables.forEach(function(table) {
table.style.backgroundColor = "#242426";
});
linksTitle.forEach(function(link) {
link.style.color = "#ffffff";
});
copyright.style.backgroundColor = "#232325";
copyrightH3.style.color = "#ffffff";
navbarLogo.src = "./assets/asset 45.png";
} else {
document.body.style.backgroundColor = "#ffffff";
document.documentElement.style.setProperty("--primary-text-color", "#183b56");
document.documentElement.style.setProperty("--secondary-text-color", "#577592");
footer.style.backgroundColor = "#ebf2fa";
tables.forEach(function(table) {
table.style.backgroundColor = "#e9ebff";
});
linksTitle.forEach(function(link) {
link.style.color = "rgb(33, 28, 28)";
});
copyright.style.backgroundColor = "#d6d9fd";
copyrightH3.style.color = "rgb(33, 28, 28)";
navbarLogo.src = "./assets/asset 41.png";
}
};
5 changes: 5 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -768,3 +768,8 @@ table .ribbon::after {
transform: translateY(3px);
}
}

#mode-switch-icon{
width: 22px;
cursor: pointer;
}