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 { public bdTheme(brightValueArg: string, darkValueArg: string): CSSResult {
let returnCssVar: string; 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( const existingTriplet = this.bdVarTripletStore.find(
(tripletArg) => (tripletArg) =>
tripletArg.darkValue === darkValueArg && tripletArg.brightValue === brightValueArg tripletArg.darkValue === darkValueArg && tripletArg.brightValue === brightValueArg
@ -59,16 +69,17 @@ export class CssManager {
darkValue: darkValueArg, darkValue: darkValueArg,
}; };
this.bdVarTripletStore.push(newTriplet); this.bdVarTripletStore.push(newTriplet);
this.domtoolsPromise.then(async (domtoolsArg) => { this.domtoolsPromise.then(async (domtoolsArg) => {
await domtoolsArg.domReady.promise; await domtoolsArg.domReady.promise;
document.body.style.setProperty( document.body.style.setProperty(
newTriplet.cssVarName, newTriplet.cssVarName,
domtoolsArg.themeManager.goBrightBoolean ? newTriplet.brightValue : newTriplet.darkValue defaultValue
); );
}); });
returnCssVar = newTriplet.cssVarName; returnCssVar = newTriplet.cssVarName;
} }
return plugins.lit.unsafeCSS(`var(${returnCssVar}, ${darkValueArg})`); return plugins.lit.unsafeCSS(`var(${returnCssVar}, ${defaultValue})`);
} }
public cssGridColumns = (amountOfColumnsArg: number, gapSizeArg: number): CSSResult => { public cssGridColumns = (amountOfColumnsArg: number, gapSizeArg: number): CSSResult => {