1
Fork 0

Make Themed Logo aware of whether its been applied already.

This commit is contained in:
Bauke 2023-12-16 18:39:15 +01:00
parent ec46b3b373
commit f56f82b9f0
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 11 additions and 4 deletions

View File

@ -1,8 +1,9 @@
import {log, querySelector} from "../../utilities/exports.js";
export function runThemedLogoFeature() {
themedLogo();
if (themedLogo()) {
log("Themed Logo: Initialized.");
}
}
const tildesLogo = `
@ -19,7 +20,12 @@ const tildesLogo = `
</svg>
`;
function themedLogo() {
function themedLogo(): boolean {
const siteHeader = querySelector<HTMLElement>(".site-header-logo");
if (siteHeader.dataset.trxThemedLogo === "true") {
return false;
}
let themedLogo = tildesLogo;
for (const customProperty of tildesLogo.match(/var\(--.+\)/g) ?? []) {
let color = window
@ -33,6 +39,7 @@ function themedLogo() {
}
const encodedSvg = encodeURIComponent(themedLogo);
const siteHeader = querySelector<HTMLElement>(".site-header-logo");
siteHeader.dataset.trxThemedLogo = "true";
siteHeader.style.backgroundImage = `url("data:image/svg+xml,${encodedSvg}")`;
return true;
}