-
Notifications
You must be signed in to change notification settings - Fork 25
StyleBuilder Struct
Ed Charbeneau edited this page Jan 16, 2020
·
1 revision
Creates a StyleBuilder used to define conditional inline styles used in a component. Call Build() to return the completed style as a string. StyleBuilder has a traditional constructor and two functional (static) convenience methods.
public struct StyleBuilder
Creates a StyleBuilder used to define conditional inline style used in a component. Call Build() to return the completed style as a string.
Initializes a new instance of the StyleBuilder struct.
public StyleBuilder(string prop, string value)
string StyleToRender =>
new StyleBuilder("color", "white")
.AddStyle("border", "1px solid black")
.Build();
// StyleToRender: "color:white;border:1px solid black"
Initializes a new instance of the StyleBuilder struct with a default initial value.
public static StyleBuilder Default(string prop, string value)
string StyleToRender =>
StyleBuilder.Default("color", "white")
.AddStyle("border", "1px solid black")
.Build();
// StyleToRender: "color:white;border:1px solid black"
Initializes a new instance of the StyleBuilder struct with a string.Empty
value.
public static StyleBuilder Empty()
string StyleToRender =>
StyleBuilder.Empty()
.AddStyle("border", "1px solid black", when: true)
.Build();
// StyleToRender: "border:1px solid black"