Added Dark Mode and working on color scheme

This commit is contained in:
its-michaelroy
2024-09-05 11:14:46 -04:00
parent 7fee0c8fc0
commit e58af57ab3
5 changed files with 106 additions and 20 deletions

19
assets/js/darkmode.js Normal file
View File

@@ -0,0 +1,19 @@
document.addEventListener("DOMContentLoaded", function () {
const body = document.body;
const themeToggle = document.getElementById("theme-toggle");
themeToggle.addEventListener("click", function () {
body.classList.toggle("dark-mode");
toggleThemeIcon();
});
function toggleThemeIcon() {
if (body.classList.contains("dark-mode")) {
themeToggle.innerHTML = '<i class="fas fa-sun"></i>';
} else {
themeToggle.innerHTML = '<i class="fas fa-moon"></i>';
}
}
toggleThemeIcon(); // Set initial icon based on the current theme
});

14
assets/js/fullparagrph.js Normal file
View File

@@ -0,0 +1,14 @@
function toggleParagraph() {
var spans = document.querySelectorAll("#more");
var btnText = document.querySelector(".learn-more");
spans.forEach(function (span) {
span.classList.toggle("hidden");
});
if (spans[0].classList.contains("hidden")) {
btnText.textContent = "Learn More";
} else {
btnText.textContent = "Less";
}
}