mirror of
https://github.com/Damillora/Yuika
synced 2024-11-22 09:17:33 +00:00
feat(theme): persist dark mode
This commit is contained in:
parent
5394121818
commit
c7187ebcc4
@ -1,14 +1,27 @@
|
|||||||
|
function setDarkMode() {
|
||||||
$(document).ready(function () {
|
if (!window.localStorage.getItem('theme') && window.document.body.getAttribute("data-theme")){
|
||||||
$("#darkMode").click(function () {
|
window.localStorage.setItem('theme', window.document.body.getAttribute("data-theme"));
|
||||||
if (window.document.body.getAttribute("data-theme") != "dark") {
|
}
|
||||||
window.document.body.setAttribute("data-theme", "dark");
|
if (window.document.body.getAttribute("data-theme") == "dark") {
|
||||||
$("#darkMode i").text("brightness_high");
|
$("#darkMode i").text("brightness_high");
|
||||||
$("#darkMode p").text("Light Mode");
|
$("#darkMode p").text("Light Mode");
|
||||||
} else {
|
} else {
|
||||||
window.document.body.setAttribute("data-theme", "light");
|
|
||||||
$("#darkMode i").text("brightness_low");
|
$("#darkMode i").text("brightness_low");
|
||||||
$("#darkMode p").text("Dark Mode");
|
$("#darkMode p").text("Dark Mode");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (window.localStorage.getItem('theme')) {
|
||||||
|
window.document.body.setAttribute("data-theme", window.localStorage.getItem("theme"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
setDarkMode();
|
||||||
|
$("#darkMode").click(function () {
|
||||||
|
if (window.document.body.getAttribute("data-theme") != "dark") {
|
||||||
|
window.document.body.setAttribute("data-theme", "dark");
|
||||||
|
} else {
|
||||||
|
window.document.body.setAttribute("data-theme", "light");
|
||||||
|
}
|
||||||
|
setDarkMode();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user