Skip to content

Commit 9f5a8cc

Browse files
committed
Merge branch 'fix-label' into refactor-dynamic
2 parents 2b5c187 + c81d0a9 commit 9f5a8cc

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs renamed to src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

6+
using Microsoft.AspNetCore.Components.Rendering;
7+
68
namespace BootstrapBlazor.Components;
79

810
/// <summary>
911
/// BootstrapInputGroupLabel 组件
1012
/// </summary>
11-
public partial class BootstrapInputGroupLabel
13+
public sealed class BootstrapInputGroupLabel : DisplayBase<string>
1214
{
1315
private string? ClassString => CssBuilder.Default()
1416
.AddClass("input-group-text", IsInputGroupLabel)
@@ -54,7 +56,7 @@ public partial class BootstrapInputGroupLabel
5456
private bool IsInputGroupLabel => InputGroup != null;
5557

5658
/// <summary>
57-
/// OnParametersSet 方法
59+
/// <inheritdoc/>
5860
/// </summary>
5961
protected override void OnParametersSet()
6062
{
@@ -65,4 +67,26 @@ protected override void OnParametersSet()
6567
DisplayText ??= FieldIdentifier?.GetDisplayName();
6668
}
6769
}
70+
71+
/// <summary>
72+
/// <inheritdoc/>
73+
/// </summary>
74+
/// <param name="builder"></param>
75+
protected override void BuildRenderTree(RenderTreeBuilder builder)
76+
{
77+
builder.OpenElement(0, TagName);
78+
builder.AddMultipleAttributes(1, AdditionalAttributes);
79+
builder.AddAttribute(2, "class", ClassString);
80+
builder.AddAttribute(3, "style", StyleString);
81+
builder.AddAttribute(4, "required", Required);
82+
if (ChildContent != null)
83+
{
84+
builder.AddContent(5, ChildContent);
85+
}
86+
else
87+
{
88+
builder.AddContent(6, DisplayText);
89+
}
90+
builder.CloseElement();
91+
}
6892
}

src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)