From e9ccc83ec55b4f3c099190aad5bf887e8ca553b2 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 28 Sep 2025 09:26:55 +0800 Subject: [PATCH 1/4] =?UTF-8?q?wip:=20=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Utils/CssBuilder.cs | 68 ++----------------------- 1 file changed, 3 insertions(+), 65 deletions(-) diff --git a/src/BootstrapBlazor/Utils/CssBuilder.cs b/src/BootstrapBlazor/Utils/CssBuilder.cs index a67669c64d9..56e589bcf2c 100644 --- a/src/BootstrapBlazor/Utils/CssBuilder.cs +++ b/src/BootstrapBlazor/Utils/CssBuilder.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone +using System.Globalization; + namespace BootstrapBlazor.Components; /// @@ -105,70 +107,6 @@ public CssBuilder AddClassFromAttributes(IDictionary? additional return this; } - /// - /// Adds a raw string to the builder that will be concatenated with the next style or value added to the builder. - /// - /// style property name - /// CSS style to conditionally add. - /// CssBuilder - public CssBuilder AddStyle(string key, string? value) - { - if (!string.IsNullOrEmpty(value)) stringBuffer.Add($"{key}: {value};"); - return this; - } - - /// - /// Adds a conditional css Style to the builder with space separator. - /// - /// style property name - /// CSS style to conditionally add. - /// Condition in which the CSS style is added. - /// CssBuilder - public CssBuilder AddStyle(string key, string? value, bool when = true) => when ? AddStyle(key, value) : this; - - /// - /// Adds a conditional css Style to the builder with space separator. - /// - /// style property name - /// CSS style to conditionally add. - /// Condition in which the CSS Style is added. - /// CssBuilder - public CssBuilder AddStyle(string key, string? value, Func when) => AddStyle(key, value, when()); - - /// - /// Adds a conditional css Style to the builder with space separator. - /// - /// style property name - /// Function that returns a css Style to conditionally add. - /// Condition in which the CSS Style is added. - /// CssBuilder - public CssBuilder AddStyle(string key, Func value, bool when = true) => when ? AddStyle(key, value()) : this; - - /// - /// Adds a conditional css Style to the builder with space separator. - /// - /// style property name - /// Function that returns a css Style to conditionally add. - /// Condition in which the CSS Style is added. - /// CssBuilder - public CssBuilder AddStyle(string key, Func value, Func when) => AddStyle(key, value, when()); - - /// - /// Adds a conditional nested CssBuilder to the builder with space separator. - /// - /// CSS Style to conditionally add. - /// Condition in which the CSS Style is added. - /// CssBuilder - public CssBuilder AddStyle(CssBuilder builder, bool when = true) => when ? AddClass(builder.Build()) : this; - - /// - /// Adds a conditional CSS Class to the builder with space separator. - /// - /// CSS Class to conditionally add. - /// Condition in which the CSS Class is added. - /// CssBuilder - public CssBuilder AddStyle(CssBuilder builder, Func when) => AddClass(builder, when()); - /// /// Adds a conditional css Style when it exists in a dictionary to the builder with space separator. /// Null safe operation. @@ -179,7 +117,7 @@ public CssBuilder AddStyleFromAttributes(IDictionary? additional { if (additionalAttributes != null && additionalAttributes.TryGetValue("style", out var c)) { - var styleList = c?.ToString(); + var styleList = Convert.ToString(c, CultureInfo.InvariantCulture); AddClass(styleList); } return this; From ef9c023e9fac64d44345238dabf51bc9c2cb8bbf Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 28 Sep 2025 10:24:28 +0800 Subject: [PATCH 2/4] refactor: use AddClass instead AddStyle --- .../Components/AutoFill/AutoFill.razor.cs | 5 +++-- .../Components/Badge/ShieldBadge.razor.cs | 12 ++++++------ .../Components/Captcha/Captcha.razor.cs | 8 ++++---- src/BootstrapBlazor/Components/Card/Card.razor.cs | 2 +- .../Components/Drawer/Drawer.razor.cs | 6 +++--- .../Components/EditorForm/EditorForm.razor.cs | 2 +- .../Components/Label/BootstrapLabel.razor.cs | 2 +- .../Components/Logout/Logout.razor.cs | 2 +- .../Components/Navbar/NavbarGroup.razor.cs | 2 +- .../Components/Toolbar/Toolbar.razor.cs | 2 +- .../Components/ValidateForm/ValidateForm.razor.cs | 2 +- 11 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs b/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs index 10690174c5b..d1e44ba5650 100644 --- a/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs +++ b/src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Components.Web.Virtualization; using Microsoft.Extensions.Localization; +using System.Globalization; namespace BootstrapBlazor.Components; @@ -150,8 +151,8 @@ public partial class AutoFill .AddClass($"text-danger", IsValid.HasValue && !IsValid.Value) .Build(); - private string? PlaceHolderStyleString => RowHeight != 50f - ? CssBuilder.Default().AddStyle("height", $"{RowHeight}px").Build() + private string? PlaceHolderStyleString => Math.Abs(RowHeight - 50f) > 0.1f + ? CssBuilder.Default().AddClass($"height: {RowHeight.ToString(CultureInfo.InvariantCulture)}px;").Build() : null; /// diff --git a/src/BootstrapBlazor/Components/Badge/ShieldBadge.razor.cs b/src/BootstrapBlazor/Components/Badge/ShieldBadge.razor.cs index c1cc6ebe4f3..9066a5d66aa 100644 --- a/src/BootstrapBlazor/Components/Badge/ShieldBadge.razor.cs +++ b/src/BootstrapBlazor/Components/Badge/ShieldBadge.razor.cs @@ -69,12 +69,12 @@ public partial class ShieldBadge .Build(); private string? StyleString => CssBuilder.Default() - .AddStyle("--bb-shield-badge-icon-color", IconColor, !string.IsNullOrEmpty(IconColor)) - .AddStyle("--bb-shield-badge-label-color", LabelColor, !string.IsNullOrEmpty(LabelColor)) - .AddStyle("--bb-shield-badge-label-bg", LabelBackgroundColor, !string.IsNullOrEmpty(LabelBackgroundColor)) - .AddStyle("--bb-shield-badge-text-color", TextColor, !string.IsNullOrEmpty(TextColor)) - .AddStyle("--bb-shield-badge-text-bg", TextBackgroundColor, !string.IsNullOrEmpty(TextBackgroundColor)) - .AddStyle("--bb-shield-badge-radius", $"{Math.Max(0, Radius)}px", Radius != 3) + .AddClass($"--bb-shield-badge-icon-color: {IconColor};", !string.IsNullOrEmpty(IconColor)) + .AddClass($"--bb-shield-badge-label-color: {LabelColor};", !string.IsNullOrEmpty(LabelColor)) + .AddClass($"--bb-shield-badge-label-bg: {LabelBackgroundColor};", !string.IsNullOrEmpty(LabelBackgroundColor)) + .AddClass($"--bb-shield-badge-text-color: {TextColor};", !string.IsNullOrEmpty(TextColor)) + .AddClass($"--bb-shield-badge-text-bg: {TextBackgroundColor};", !string.IsNullOrEmpty(TextBackgroundColor)) + .AddClass($"--bb-shield-badge-radius: {Math.Max(0, Radius)}px;", Radius != 3) .Build(); private string? IconString => CssBuilder.Default("shield-badge-icon") diff --git a/src/BootstrapBlazor/Components/Captcha/Captcha.razor.cs b/src/BootstrapBlazor/Components/Captcha/Captcha.razor.cs index 13ff538f54a..36c1a9606db 100644 --- a/src/BootstrapBlazor/Components/Captcha/Captcha.razor.cs +++ b/src/BootstrapBlazor/Components/Captcha/Captcha.razor.cs @@ -20,15 +20,15 @@ public partial class Captcha /// 获得 组件宽度 /// private string? StyleString => CssBuilder.Default() - .AddStyle("width", $"{Width + 42}px", Width > 0) + .AddClass($"width: {Width + 42}px;", Width > 0) .Build(); /// /// 获得 加载图片失败样式 /// private string? FailedStyle => CssBuilder.Default() - .AddStyle("width", $"{Width}px", Width > 0) - .AddStyle("height", $"{Height}px", Height > 0) + .AddClass($"width: {Width}px;", Width > 0) + .AddClass($"height: {Height}px;", Height > 0) .Build(); /// @@ -219,7 +219,7 @@ private CaptchaOption GetCaptchaOption() private static bool CalcStddev(List trails) { var ret = false; - if (trails.Any()) + if (trails.Count > 0) { var average = trails.Sum() * 1.0 / trails.Count; var dev = trails.Select(t => t - average); diff --git a/src/BootstrapBlazor/Components/Card/Card.razor.cs b/src/BootstrapBlazor/Components/Card/Card.razor.cs index bdd362a3bd5..fbd1d12a7a6 100644 --- a/src/BootstrapBlazor/Components/Card/Card.razor.cs +++ b/src/BootstrapBlazor/Components/Card/Card.razor.cs @@ -127,7 +127,7 @@ public partial class Card private IIconTheme? IconTheme { get; set; } private string? HeaderStyleString => CssBuilder.Default() - .AddStyle("--bs-card-cap-padding-y", HeaderPaddingY) + .AddClass($"--bs-card-cap-padding-y: {HeaderPaddingY};", !string.IsNullOrEmpty(HeaderPaddingY)) .AddStyleFromAttributes(AdditionalAttributes) .Build(); diff --git a/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs b/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs index ef31ce0b687..47ab5ce571a 100644 --- a/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs +++ b/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs @@ -19,7 +19,7 @@ public partial class Drawer .Build(); private string? StyleString => CssBuilder.Default() - .AddStyle("--bb-drawer-position", Position) + .AddClass($"--bb-drawer-position: {Position};") .AddClass($"--bb-drawer-zindex: {ZIndex};", ZIndex.HasValue) .AddStyleFromAttributes(AdditionalAttributes) .Build(); @@ -28,8 +28,8 @@ public partial class Drawer /// 获得 抽屉 Style 字符串 /// private string? DrawerStyleString => CssBuilder.Default() - .AddStyle("--bb-drawer-width", Width, Placement != Placement.Top && Placement != Placement.Bottom) - .AddStyle("--bb-drawer-height", Height, Placement == Placement.Top || Placement == Placement.Bottom) + .AddClass($"--bb-drawer-width: {Width};", Placement != Placement.Top && Placement != Placement.Bottom) + .AddClass($"--bb-drawer-height: {Height};", Placement == Placement.Top || Placement == Placement.Bottom) .Build(); /// diff --git a/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs b/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs index 43956eef2db..fc97a9dae6f 100644 --- a/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs +++ b/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs @@ -44,7 +44,7 @@ public partial class EditorForm : IShowLabel .Build(); private string? FormStyleString => CssBuilder.Default() - .AddStyle("--bb-row-label-width", $"{LabelWidth}px", LabelWidth.HasValue) + .AddClass($"--bb-row-label-width: {LabelWidth}px;", LabelWidth.HasValue) .Build(); /// diff --git a/src/BootstrapBlazor/Components/Label/BootstrapLabel.razor.cs b/src/BootstrapBlazor/Components/Label/BootstrapLabel.razor.cs index e0118c6d65e..106a861d93d 100644 --- a/src/BootstrapBlazor/Components/Label/BootstrapLabel.razor.cs +++ b/src/BootstrapBlazor/Components/Label/BootstrapLabel.razor.cs @@ -39,7 +39,7 @@ public partial class BootstrapLabel .Build(); private string? StyleString => CssBuilder.Default() - .AddStyle($"--bb-row-label-width", $"{LabelWidth}px", LabelWidth.HasValue) + .AddClass($"--bb-row-label-width: {LabelWidth}px;", LabelWidth.HasValue) .AddStyleFromAttributes(AdditionalAttributes) .Build(); diff --git a/src/BootstrapBlazor/Components/Logout/Logout.razor.cs b/src/BootstrapBlazor/Components/Logout/Logout.razor.cs index 5176a741a4b..7c30a4aeb2c 100644 --- a/src/BootstrapBlazor/Components/Logout/Logout.razor.cs +++ b/src/BootstrapBlazor/Components/Logout/Logout.razor.cs @@ -81,7 +81,7 @@ public partial class Logout .Build(); private string? AvatarStyleString => CssBuilder.Default() - .AddStyle("--bb-logout-user-avatar-border-radius", AvatarRadius, !string.IsNullOrEmpty(AvatarRadius)) + .AddClass($"--bb-logout-user-avatar-border-radius: {AvatarRadius};", !string.IsNullOrEmpty(AvatarRadius)) .Build(); /// diff --git a/src/BootstrapBlazor/Components/Navbar/NavbarGroup.razor.cs b/src/BootstrapBlazor/Components/Navbar/NavbarGroup.razor.cs index 469a497b427..d7aed1dcb44 100644 --- a/src/BootstrapBlazor/Components/Navbar/NavbarGroup.razor.cs +++ b/src/BootstrapBlazor/Components/Navbar/NavbarGroup.razor.cs @@ -34,7 +34,7 @@ public partial class NavbarGroup .Build(); private string? StyleString => CssBuilder.Default() - .AddStyle("--bs-scroll-height", Height, IsScrolling) + .AddClass($"--bs-scroll-height: {Height};", !string.IsNullOrEmpty(Height)) .AddStyleFromAttributes(AdditionalAttributes) .Build(); diff --git a/src/BootstrapBlazor/Components/Toolbar/Toolbar.razor.cs b/src/BootstrapBlazor/Components/Toolbar/Toolbar.razor.cs index fdac101cc0b..a66162f8141 100644 --- a/src/BootstrapBlazor/Components/Toolbar/Toolbar.razor.cs +++ b/src/BootstrapBlazor/Components/Toolbar/Toolbar.razor.cs @@ -27,7 +27,7 @@ public partial class Toolbar .Build(); private string? StyleString => CssBuilder.Default() - .AddStyle("flex-wrap", "wrap", IsWrap) + .AddClass("flex-wrap: wrap;", IsWrap) .AddStyleFromAttributes(AdditionalAttributes) .Build(); } diff --git a/src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs b/src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs index 9f22e40d4f2..cb701b8f477 100644 --- a/src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs +++ b/src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs @@ -131,7 +131,7 @@ public partial class ValidateForm private string? ShowAllInvalidResultString => ShowAllInvalidResult ? "true" : null; private string? StyleString => CssBuilder.Default() - .AddStyle("--bb-row-label-width", $"{LabelWidth}px", LabelWidth.HasValue) + .AddClass($"--bb-row-label-width: {LabelWidth}px;", LabelWidth.HasValue) .Build(); /// From d6d6be1f7841aac84665fdab90f8cd7d03ee9d24 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 28 Sep 2025 10:59:22 +0800 Subject: [PATCH 3/4] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=20Drawer=20?= =?UTF-8?q?=E6=8A=BD=E5=B1=89=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs | 6 ++++-- test/UnitTest/Components/DrawerTest.cs | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs b/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs index 47ab5ce571a..fa4621c3966 100644 --- a/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs +++ b/src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs @@ -28,10 +28,12 @@ public partial class Drawer /// 获得 抽屉 Style 字符串 /// private string? DrawerStyleString => CssBuilder.Default() - .AddClass($"--bb-drawer-width: {Width};", Placement != Placement.Top && Placement != Placement.Bottom) - .AddClass($"--bb-drawer-height: {Height};", Placement == Placement.Top || Placement == Placement.Bottom) + .AddClass($"--bb-drawer-width: {Width};", !string.IsNullOrEmpty(Width) && !IsVertical) + .AddClass($"--bb-drawer-height: {Height};", !string.IsNullOrEmpty(Height) && IsVertical) .Build(); + private bool IsVertical => Placement == Placement.Top || Placement == Placement.Bottom; + /// /// 获得 抽屉样式 /// diff --git a/test/UnitTest/Components/DrawerTest.cs b/test/UnitTest/Components/DrawerTest.cs index 85a8b4c1d7c..b3987d4d50e 100644 --- a/test/UnitTest/Components/DrawerTest.cs +++ b/test/UnitTest/Components/DrawerTest.cs @@ -11,13 +11,13 @@ public class DrawerTest : BootstrapBlazorTestBase public void Width_Ok() { var cut = Context.RenderComponent(builder => builder.Add(a => a.Width, "100px")); - Assert.Contains("width: 100px", cut.Markup); + Assert.Contains("--bb-drawer-width: 100px;", cut.Markup); cut.SetParametersAndRender(pb => { pb.Add(a => a.Width, ""); }); - Assert.DoesNotContain("width:", cut.Markup); + Assert.DoesNotContain("--bb-drawer-width", cut.Markup); } [Fact] @@ -28,13 +28,13 @@ public void Height_Ok() builder.Add(a => a.Height, "100px"); builder.Add(a => a.Placement, Placement.Top); }); - Assert.Contains("height: 100px", cut.Markup); + Assert.Contains("--bb-drawer-height: 100px", cut.Markup); cut.SetParametersAndRender(pb => { pb.Add(a => a.Height, ""); }); - Assert.DoesNotContain("height:", cut.Markup); + Assert.DoesNotContain("--bb-drawer-height:", cut.Markup); } [Fact] From 32cc54c901d907de7ae87b6c9df1216a86b0e1bf Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 28 Sep 2025 10:59:35 +0800 Subject: [PATCH 4/4] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=80=A7?= =?UTF-8?q?=E8=83=BD=E6=9B=B4=E6=96=B0=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Utils/CssBuilder.cs | 30 ++++++++--- test/UnitTest/Utils/CssBuilderTest.cs | 66 ------------------------- 2 files changed, 23 insertions(+), 73 deletions(-) diff --git a/src/BootstrapBlazor/Utils/CssBuilder.cs b/src/BootstrapBlazor/Utils/CssBuilder.cs index 56e589bcf2c..dcfdb703958 100644 --- a/src/BootstrapBlazor/Utils/CssBuilder.cs +++ b/src/BootstrapBlazor/Utils/CssBuilder.cs @@ -4,6 +4,7 @@ // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone using System.Globalization; +using System.Text; namespace BootstrapBlazor.Components; @@ -12,7 +13,8 @@ namespace BootstrapBlazor.Components; /// public class CssBuilder { - private readonly List stringBuffer; + private readonly StringBuilder _builder = new(); + private bool _hasConent; /// /// Creates a CssBuilder used to define conditional CSS classes used in a component. @@ -28,8 +30,11 @@ public class CssBuilder /// protected CssBuilder(string? value) { - stringBuffer = []; - AddClass(value); + if (!string.IsNullOrEmpty(value)) + { + _builder.Append(value); + _hasConent = true; + } } /// @@ -39,7 +44,18 @@ protected CssBuilder(string? value) /// CssBuilder public CssBuilder AddClass(string? value) { - if (!string.IsNullOrEmpty(value)) stringBuffer.Add(value); + if (!string.IsNullOrEmpty(value)) + { + if (_hasConent) + { + _builder.Append(' '); + } + else + { + _hasConent = true; + } + _builder.Append(value); + } return this; } @@ -101,8 +117,8 @@ public CssBuilder AddClassFromAttributes(IDictionary? additional { if (additionalAttributes != null && additionalAttributes.TryGetValue("class", out var c)) { - var classList = c?.ToString(); - AddClass(classList); + var classString = Convert.ToString(c, CultureInfo.InvariantCulture); + AddClass(classString); } return this; } @@ -127,5 +143,5 @@ public CssBuilder AddStyleFromAttributes(IDictionary? additional /// Finalize the completed CSS Classes as a string. /// /// string - public string? Build() => stringBuffer.Count > 0 ? string.Join(" ", stringBuffer) : null; + public string? Build() => _hasConent ? _builder.ToString() : null; } diff --git a/test/UnitTest/Utils/CssBuilderTest.cs b/test/UnitTest/Utils/CssBuilderTest.cs index 27c02e19955..ebaf19063f9 100644 --- a/test/UnitTest/Utils/CssBuilderTest.cs +++ b/test/UnitTest/Utils/CssBuilderTest.cs @@ -21,51 +21,6 @@ public void AddClass_When() Assert.Contains("cls_test", classString); } - [Fact] - public void AddStyle_When() - { - var classString = CssBuilder.Default() - .AddStyle("width", () => "cls_test", () => false) - .Build(); - Assert.DoesNotContain("widht: cls_test;", classString); - - classString = CssBuilder.Default() - .AddStyle("width", () => "cls_test", false) - .Build(); - Assert.DoesNotContain("widht: cls_test;", classString); - - classString = CssBuilder.Default() - .AddStyle("width", "cls_test", false) - .Build(); - Assert.DoesNotContain("widht: cls_test;", classString); - - classString = CssBuilder.Default() - .AddStyle("width", () => "cls_test", () => true) - .Build(); - Assert.Contains("width: cls_test;", classString); - - classString = CssBuilder.Default() - .AddStyle("width", () => "cls_test", true) - .Build(); - Assert.Contains("width: cls_test;", classString); - - classString = CssBuilder.Default() - .AddStyle("width", "cls_test", true) - .Build(); - Assert.Contains("width: cls_test;", classString); - - classString = CssBuilder.Default() - .AddStyle("width", "cls_test", () => true) - .Build(); - Assert.Contains("width: cls_test;", classString); - - classString = CssBuilder.Default() - .AddStyle("width", "cls_test_width") - .AddStyle("height", "cls_test_height") - .Build(); - Assert.Equal("width: cls_test_width; height: cls_test_height;", classString); - } - [Fact] public void AddClass_Builder() { @@ -82,27 +37,6 @@ public void AddClass_Builder() Assert.Contains("cls_test", classString); } - [Fact] - public void AddStyle_Builder() - { - var builder = CssBuilder.Default("width: cls_test_width;"); - - var classString = CssBuilder.Default() - .AddStyle(builder, false) - .Build(); - Assert.DoesNotContain("width: cls_test_width;", classString); - - classString = CssBuilder.Default() - .AddStyle(builder, () => true) - .Build(); - Assert.Contains("width: cls_test_width;", classString); - - classString = CssBuilder.Default() - .AddStyle(builder, true) - .Build(); - Assert.Contains("width: cls_test_width;", classString); - } - [Fact] public void AddStyleFromAttributes_Ok() {