From fcb2a9ef4f1413681ae9efb843a397578be07c86 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 1 Feb 2025 13:40:30 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20LabelWidth=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Label/BootstrapLabel.razor | 2 +- .../Components/Label/BootstrapLabel.razor.cs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Label/BootstrapLabel.razor b/src/BootstrapBlazor/Components/Label/BootstrapLabel.razor index a8a0bf750d7..e2cc22ec2e0 100644 --- a/src/BootstrapBlazor/Components/Label/BootstrapLabel.razor +++ b/src/BootstrapBlazor/Components/Label/BootstrapLabel.razor @@ -14,5 +14,5 @@ else @code { RenderFragment RenderLabel => - @; + @; } diff --git a/src/BootstrapBlazor/Components/Label/BootstrapLabel.razor.cs b/src/BootstrapBlazor/Components/Label/BootstrapLabel.razor.cs index 60363472b15..9de80e6afd4 100644 --- a/src/BootstrapBlazor/Components/Label/BootstrapLabel.razor.cs +++ b/src/BootstrapBlazor/Components/Label/BootstrapLabel.razor.cs @@ -23,12 +23,22 @@ public partial class BootstrapLabel [Parameter] public bool? ShowLabelTooltip { get; set; } + /// + /// 获得/设置 标签宽度 默认 null 未设置使用全局设置 --bb-row-label-width 值 + /// + [Parameter] + public int? LabelWidth { get; set; } + private bool _showTooltip; private string? ClassString => CssBuilder.Default("form-label") .AddClassFromAttributes(AdditionalAttributes) .Build(); + private string? StyleString => CssBuilder.Default() + .AddClass($"--bb-row-label-width: {LabelWidth}px;", LabelWidth.HasValue) + .Build(); + /// /// /// From 1271a7f4357bdb905bba75e882978c1027f0334e Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 1 Feb 2025 13:40:40 +0800 Subject: [PATCH 2/3] =?UTF-8?q?doc:=20=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Samples/EditorForms.razor | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/BootstrapBlazor.Server/Components/Samples/EditorForms.razor b/src/BootstrapBlazor.Server/Components/Samples/EditorForms.razor index 7585671c5a6..3e3169ae42e 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/EditorForms.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/EditorForms.razor @@ -21,12 +21,12 @@ - - - + + + - @@ -41,11 +41,11 @@ - - + + - @@ -57,8 +57,8 @@

@((MarkupString)Localizer["AutoGenerateDescription"].Value)

- - + + @@ -70,22 +70,22 @@ - - + +
-
- +
- +
-
@@ -98,10 +98,10 @@ - + - @@ -119,11 +119,11 @@ - +
-
@@ -132,4 +132,4 @@ - + From 62e06047bc35b431f0628e8f606f403387cb5bdf Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 1 Feb 2025 13:42:41 +0800 Subject: [PATCH 3/3] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/TextareaTest.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/UnitTest/Components/TextareaTest.cs b/test/UnitTest/Components/TextareaTest.cs index 99bde4a2d31..63a60b918df 100644 --- a/test/UnitTest/Components/TextareaTest.cs +++ b/test/UnitTest/Components/TextareaTest.cs @@ -14,6 +14,12 @@ public void IsShowLabel_OK() var component = cut.FindComponent(); Assert.NotNull(component); + + component.SetParametersAndRender(pb => + { + pb.Add(a => a.LabelWidth, 120); + }); + cut.Contains("style=\"--bb-row-label-width: 120px;\""); } [Fact]