fix(core): update

This commit is contained in:
Philipp Kunz 2022-04-19 10:50:31 +02:00
parent a7e1a02b52
commit a3ab19e5db

View File

@ -46,6 +46,16 @@ export class CssManager {
public bdTheme(brightValueArg: string, darkValueArg: string): CSSResult {
let returnCssVar: string;
// lets determine the default value for quick page rendering.
let defaultValue: string;
if (domtools.DomTools.getGlobalDomToolsSync()) {
defaultValue = domtools.DomTools.getGlobalDomToolsSync().themeManager.goBrightBoolean ? brightValueArg : darkValueArg;
} else {
defaultValue = darkValueArg
}
const existingTriplet = this.bdVarTripletStore.find(
(tripletArg) =>
tripletArg.darkValue === darkValueArg && tripletArg.brightValue === brightValueArg
@ -59,16 +69,17 @@ export class CssManager {
darkValue: darkValueArg,
};
this.bdVarTripletStore.push(newTriplet);
this.domtoolsPromise.then(async (domtoolsArg) => {
await domtoolsArg.domReady.promise;
document.body.style.setProperty(
newTriplet.cssVarName,
domtoolsArg.themeManager.goBrightBoolean ? newTriplet.brightValue : newTriplet.darkValue
defaultValue
);
});
returnCssVar = newTriplet.cssVarName;
}
return plugins.lit.unsafeCSS(`var(${returnCssVar}, ${darkValueArg})`);
return plugins.lit.unsafeCSS(`var(${returnCssVar}, ${defaultValue})`);
}
public cssGridColumns = (amountOfColumnsArg: number, gapSizeArg: number): CSSResult => {