mirror of
https://github.com/dotnetcore/BootstrapBlazor.git
synced 2025-12-20 10:26:41 +08:00
refactor(BootstrapInputGroupLabel): use DynamicElement unified tag (#6101)
* refactor: 精简代码 * style: 代码格式化
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
.input-group {
|
||||
.input-group {
|
||||
> .datetime-picker,
|
||||
> .select,
|
||||
> .switch,
|
||||
|
||||
@@ -1,29 +1,13 @@
|
||||
@namespace BootstrapBlazor.Components
|
||||
@inherits DisplayBase<string>
|
||||
|
||||
@if (IsInputGroupLabel)
|
||||
{
|
||||
<div @attributes="@AdditionalAttributes" class="@ClassString" style="@StyleString" required="@Required">
|
||||
@if (ChildContent != null)
|
||||
{
|
||||
@ChildContent
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>@DisplayText</span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<label @attributes="@AdditionalAttributes" class="@ClassString" style="@StyleString" required="@Required">
|
||||
@if (ChildContent != null)
|
||||
{
|
||||
@ChildContent
|
||||
}
|
||||
else
|
||||
{
|
||||
@DisplayText
|
||||
}
|
||||
</label>
|
||||
}
|
||||
<DynamicElement @attributes="@AdditionalAttributes" TagName="@TagName" class="@ClassString" style="@StyleString" required="@Required">
|
||||
@if (ChildContent != null)
|
||||
{
|
||||
@ChildContent
|
||||
}
|
||||
else
|
||||
{
|
||||
@DisplayText
|
||||
}
|
||||
</DynamicElement>
|
||||
|
||||
@@ -23,6 +23,8 @@ public partial class BootstrapInputGroupLabel
|
||||
.AddClassFromAttributes(AdditionalAttributes)
|
||||
.Build();
|
||||
|
||||
private string TagName => IsInputGroupLabel ? "div" : "label";
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 标签宽度 默认 null 未设置自动适应
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user