theme-color now changes with site theme

This commit is contained in:
Reijnn 2019-03-05 13:16:59 +01:00
parent e35ede04c2
commit 22c42bbd5f
3 changed files with 34 additions and 23 deletions

View file

@ -3,6 +3,7 @@
const getTheme = window.localStorage && window.localStorage.getItem("theme");
const themeToggle = document.querySelector(".theme-toggle");
const isDark = getTheme === "dark";
var metaThemeColor = document.querySelector("meta[name=theme-color]");
if (getTheme !== null) {
document.body.classList.toggle("dark-theme", isDark);
@ -15,4 +16,7 @@ themeToggle.addEventListener("click", () => {
"theme",
document.body.classList.contains("dark-theme") ? "dark" : "light",
);
document.body.classList.contains("dark-theme") ?
metaThemeColor.setAttribute("content", "#252627") : metaThemeColor.setAttribute("content", "#fafafa");
;
});