fix(core): update

This commit is contained in:
Philipp Kunz 2021-03-28 14:38:17 +00:00
parent a0cad2f4bc
commit d697fa2437

View File

@ -12,21 +12,24 @@ export class CssManager {
public dbVarTripletStore: IDbVarTriplet[] = []; public dbVarTripletStore: IDbVarTriplet[] = [];
public dbTheme(darkValueArg: string, brightValueArg: string): CSSResult { public dbTheme(darkValueArg: string, brightValueArg: string): CSSResult {
let returnCssVar: string;
const existingTriplet = this.dbVarTripletStore.find(tripletArg => tripletArg.darkValue === darkValueArg && tripletArg.brightValue === brightValueArg); const existingTriplet = this.dbVarTripletStore.find(tripletArg => tripletArg.darkValue === darkValueArg && tripletArg.brightValue === brightValueArg);
if (existingTriplet) { if (existingTriplet) {
return plugins.litElement.unsafeCSS(existingTriplet.cssVarName) returnCssVar = existingTriplet.cssVarName;
} else { } else {
const newTriplet: IDbVarTriplet = { const newTriplet: IDbVarTriplet = {
cssVarName: `--${plugins.isounique.uni()}`, cssVarName: `--${plugins.isounique.uni()}`,
brightValue: brightValueArg, brightValue: brightValueArg,
darkValue: darkValueArg darkValue: darkValueArg
} };
this.dbVarTripletStore.push(newTriplet) this.dbVarTripletStore.push(newTriplet);
document.onreadystatechange = () => { domtools.DomTools.setupDomTools().then(async (domtools) => {
document.body?.style?.setProperty(newTriplet.cssVarName, newTriplet.darkValue); await domtools.domReady.promise;
} document.body.style.setProperty(newTriplet.cssVarName, newTriplet.darkValue);
return plugins.litElement.unsafeCSS(newTriplet.cssVarName); });
returnCssVar = newTriplet.cssVarName;
} }
return plugins.litElement.unsafeCSS(`var(${returnCssVar})`);
} }
public cssGridColumns = (amountOfColumnsArg: number, gapSizeArg: number): CSSResult => { public cssGridColumns = (amountOfColumnsArg: number, gapSizeArg: number): CSSResult => {