Better variable helper flow

This commit is contained in:
2023-08-24 14:11:30 +02:00
parent a6d98a9d84
commit 82561d8dc7
3 changed files with 26 additions and 17 deletions

View File

@@ -34,7 +34,7 @@ export class VariableHelper {
return this;
}
toCss() {
public toCss() {
if (!this.property) {
return css`
${unsafeCSS(this.buildVariableName())}
@@ -61,4 +61,21 @@ export class VariableHelper {
this.defaultValue
})`;
}
// static builders for convencience
public static from(): VariableHelper {
return new VariableHelper();
}
public static fromDefaultValue(value: string | CSSResult) {
return VariableHelper.from().withDefaultValue(value);
}
public static fromProperty(property: string) {
return VariableHelper.from().withProperty(property);
}
public static fromVariableName(name: string) {
return VariableHelper.from().withVariableName(name);
}
}