mirror of https://github.com/jpanther/congo.git
🚸 Set `theme-color` using theme colour scheme
parent
4679ce485c
commit
447ce2f52a
|
@ -1,11 +1,17 @@
|
||||||
const sitePreference = document.documentElement.getAttribute("data-default-appearance");
|
const sitePreference = document.documentElement.getAttribute("data-default-appearance");
|
||||||
const userPreference = localStorage.getItem("appearance");
|
const userPreference = localStorage.getItem("appearance");
|
||||||
|
|
||||||
|
function getCSSValue(varName) {
|
||||||
|
var cssValue = window.getComputedStyle(document.documentElement).getPropertyValue(varName);
|
||||||
|
return "rgb(" + cssValue.replace(/\s+/g, "") + ")";
|
||||||
|
}
|
||||||
|
|
||||||
function setThemeColor() {
|
function setThemeColor() {
|
||||||
const metaThemeColor = document.querySelector("meta[name=theme-color]");
|
var metaThemeColor = document.querySelector("meta[name=theme-color]");
|
||||||
document.documentElement.classList.contains("dark")
|
document.documentElement.classList.contains("dark")
|
||||||
? metaThemeColor.setAttribute("content", "#27272a")
|
? metaThemeColor.setAttribute("content", getCSSValue("--color-neutral-800"))
|
||||||
: metaThemeColor.setAttribute("content", "#ffffff");
|
: metaThemeColor.setAttribute("content", getCSSValue("--color-neutral"));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sitePreference === "dark" && userPreference === null) || userPreference === "dark") {
|
if ((sitePreference === "dark" && userPreference === null) || userPreference === "dark") {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<meta http-equiv="content-language" content="{{ . }}" />
|
<meta http-equiv="content-language" content="{{ . }}" />
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta name="theme-color" content="#ffffff" />
|
<meta name="theme-color" content="rgb(255,255,255)" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||||
{{/* Title */}}
|
{{/* Title */}}
|
||||||
{{ if .IsHome -}}
|
{{ if .IsHome -}}
|
||||||
|
|
Loading…
Reference in New Issue