fix(core): update
This commit is contained in:
parent
a0cad2f4bc
commit
d697fa2437
@ -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);
|
||||||
|
domtools.DomTools.setupDomTools().then(async (domtools) => {
|
||||||
|
await domtools.domReady.promise;
|
||||||
|
document.body.style.setProperty(newTriplet.cssVarName, newTriplet.darkValue);
|
||||||
|
});
|
||||||
|
returnCssVar = newTriplet.cssVarName;
|
||||||
}
|
}
|
||||||
this.dbVarTripletStore.push(newTriplet)
|
return plugins.litElement.unsafeCSS(`var(${returnCssVar})`);
|
||||||
document.onreadystatechange = () => {
|
|
||||||
document.body?.style?.setProperty(newTriplet.cssVarName, newTriplet.darkValue);
|
|
||||||
}
|
|
||||||
return plugins.litElement.unsafeCSS(newTriplet.cssVarName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public cssGridColumns = (amountOfColumnsArg: number, gapSizeArg: number): CSSResult => {
|
public cssGridColumns = (amountOfColumnsArg: number, gapSizeArg: number): CSSResult => {
|
||||||
|
Loading…
Reference in New Issue
Block a user