theme-color now changes with site theme
This commit is contained in:
parent
e35ede04c2
commit
22c42bbd5f
3 changed files with 34 additions and 23 deletions
|
@ -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");
|
||||
;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue