Make Themed Logo aware of whether its been applied already.
This commit is contained in:
parent
ec46b3b373
commit
f56f82b9f0
|
@ -1,9 +1,10 @@
|
||||||
import {log, querySelector} from "../../utilities/exports.js";
|
import {log, querySelector} from "../../utilities/exports.js";
|
||||||
|
|
||||||
export function runThemedLogoFeature() {
|
export function runThemedLogoFeature() {
|
||||||
themedLogo();
|
if (themedLogo()) {
|
||||||
log("Themed Logo: Initialized.");
|
log("Themed Logo: Initialized.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const tildesLogo = `
|
const tildesLogo = `
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="32px" height="32px" viewBox="0 0 100 100">
|
<svg xmlns="http://www.w3.org/2000/svg" width="32px" height="32px" viewBox="0 0 100 100">
|
||||||
|
@ -19,7 +20,12 @@ const tildesLogo = `
|
||||||
</svg>
|
</svg>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function themedLogo() {
|
function themedLogo(): boolean {
|
||||||
|
const siteHeader = querySelector<HTMLElement>(".site-header-logo");
|
||||||
|
if (siteHeader.dataset.trxThemedLogo === "true") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let themedLogo = tildesLogo;
|
let themedLogo = tildesLogo;
|
||||||
for (const customProperty of tildesLogo.match(/var\(--.+\)/g) ?? []) {
|
for (const customProperty of tildesLogo.match(/var\(--.+\)/g) ?? []) {
|
||||||
let color = window
|
let color = window
|
||||||
|
@ -33,6 +39,7 @@ function themedLogo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const encodedSvg = encodeURIComponent(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}")`;
|
siteHeader.style.backgroundImage = `url("data:image/svg+xml,${encodedSvg}")`;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue