Skip to content

Commit 42852a6

Browse files
ArgoZhangice6
andauthored
feat(Row): support custom class attribute (#5113)
* feat: support custom class attribute * test: 更新单元测试 Co-Authored-By: ice6 <[email protected]> Co-Authored-By: Argo <[email protected]>
1 parent 96c3db5 commit 42852a6

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/BootstrapBlazor/Components/Row/Row.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
@inherits BootstrapModuleComponentBase
33
@attribute [BootstrapModuleAutoLoader(AutoInvokeDispose = false)]
44

5-
<div @attributes="@AdditionalAttributes" id="@Id" data-bb-toggle="row" data-bb-type="@RowType.ToDescriptionString()" data-bb-items="@ItemsPerRow.ToDescriptionString()" data-bb-colspan="@ColSpan" class="d-none">
5+
<div @attributes="@AdditionalAttributes" id="@Id" data-bb-toggle="row" data-bb-type="@RowType.ToDescriptionString()" data-bb-items="@ItemsPerRow.ToDescriptionString()" data-bb-colspan="@ColSpan" class="@ClassString">
66
@ChildContent
77
</div>

src/BootstrapBlazor/Components/Row/Row.razor.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace BootstrapBlazor.Components;
77

88
/// <summary>
9-
///
9+
/// Row 组件
1010
/// </summary>
1111
public partial class Row
1212
{
@@ -33,4 +33,8 @@ public partial class Row
3333
/// </summary>
3434
[Parameter]
3535
public RenderFragment? ChildContent { get; set; }
36+
37+
private string? ClassString => CssBuilder.Default("d-none")
38+
.AddClassFromAttributes(AdditionalAttributes)
39+
.Build();
3640
}

test/UnitTest/Components/RowTest.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ public void RowType_Normal()
1414
{
1515
pb.Add(a => a.RowType, RowType.Normal);
1616
pb.Add(a => a.ChildContent, CreateContent());
17+
pb.Add(a => a.AdditionalAttributes, new Dictionary<string, object>()
18+
{
19+
{ "class", "test-row" }
20+
});
1721
});
1822

1923
Assert.Contains("data-bb-type=\"row\"", cut.Markup);
24+
Assert.Contains("class=\"d-none test-row\"", cut.Markup);
2025
}
2126

2227
[Fact]

0 commit comments

Comments
 (0)