Skip to content

Commit

Permalink
feat(Row): support custom class attribute (#5113)
Browse files Browse the repository at this point in the history
* feat: support custom class attribute

* test: 更新单元测试

Co-Authored-By: ice6 <[email protected]>
Co-Authored-By: Argo <[email protected]>
  • Loading branch information
ArgoZhang and ice6 authored Jan 15, 2025
1 parent 96c3db5 commit 42852a6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Row/Row.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@inherits BootstrapModuleComponentBase
@attribute [BootstrapModuleAutoLoader(AutoInvokeDispose = false)]

<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">
<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">
@ChildContent
</div>
6 changes: 5 additions & 1 deletion src/BootstrapBlazor/Components/Row/Row.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace BootstrapBlazor.Components;

/// <summary>
///
/// Row 组件
/// </summary>
public partial class Row
{
Expand All @@ -33,4 +33,8 @@ public partial class Row
/// </summary>
[Parameter]
public RenderFragment? ChildContent { get; set; }

private string? ClassString => CssBuilder.Default("d-none")
.AddClassFromAttributes(AdditionalAttributes)
.Build();
}
5 changes: 5 additions & 0 deletions test/UnitTest/Components/RowTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ public void RowType_Normal()
{
pb.Add(a => a.RowType, RowType.Normal);
pb.Add(a => a.ChildContent, CreateContent());
pb.Add(a => a.AdditionalAttributes, new Dictionary<string, object>()
{
{ "class", "test-row" }
});
});

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

[Fact]
Expand Down

0 comments on commit 42852a6

Please sign in to comment.