mirror of
https://github.com/assenzostefano/class-website.git
synced 2025-06-06 00:39:12 +02:00
Technically I fixed the dark mode
This commit is contained in:
19
function.js
19
function.js
@@ -15,4 +15,21 @@ var checkbox = document.querySelector('input[name=mode]');
|
|||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
document.documentElement.classList.remove('transition');
|
document.documentElement.classList.remove('transition');
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const btn = document.querySelector(".container_toggle");
|
||||||
|
|
||||||
|
const currentTheme = localStorage.getItem("theme");
|
||||||
|
if (currentTheme == "dark") {
|
||||||
|
document.body.classList.add("dark-theme");
|
||||||
|
}
|
||||||
|
|
||||||
|
btn.addEventListener("click", function () {
|
||||||
|
document.body.classList.toggle("dark-theme");
|
||||||
|
|
||||||
|
let theme = "light";
|
||||||
|
if (document.body.classList.contains("dark-theme")) {
|
||||||
|
theme = "dark";
|
||||||
|
}
|
||||||
|
localStorage.setItem("theme", theme);
|
||||||
|
});
|
@@ -49,5 +49,5 @@
|
|||||||
<input class="container_toggle" type="checkbox" id="switch" name="mode">
|
<input class="container_toggle" type="checkbox" id="switch" name="mode">
|
||||||
<label for="switch">Toggle</label>
|
<label for="switch">Toggle</label>
|
||||||
</div>
|
</div>
|
||||||
<script src="https://1elci.it/function.js"></script>
|
<script src="/function.js"></script>
|
||||||
</body>
|
</body>
|
Reference in New Issue
Block a user