From c81d0a9f8c08cfa5ddb845f1e81f5447001fe09f Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 5 Aug 2025 20:15:19 +0800 Subject: [PATCH 01/10] =?UTF-8?q?refactor:=20=E4=BD=BF=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=94=9F=E6=88=90=E7=BB=84=E4=BB=B6=E6=94=AF=E6=8C=81?= =?UTF-8?q?=20@onclick=20=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...l.razor.cs => BootstrapInputGroupLabel.cs} | 28 +++++++++++++++++-- .../Input/BootstrapInputGroupLabel.razor | 13 --------- 2 files changed, 26 insertions(+), 15 deletions(-) rename src/BootstrapBlazor/Components/Input/{BootstrapInputGroupLabel.razor.cs => BootstrapInputGroupLabel.cs} (72%) delete mode 100644 src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs similarity index 72% rename from src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs rename to src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs index 8b1cdf0d3bf..3835400b38c 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs +++ b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs @@ -3,12 +3,14 @@ // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone +using Microsoft.AspNetCore.Components.Rendering; + namespace BootstrapBlazor.Components; /// /// BootstrapInputGroupLabel 组件 /// -public partial class BootstrapInputGroupLabel +public sealed class BootstrapInputGroupLabel : DisplayBase { private string? ClassString => CssBuilder.Default() .AddClass("input-group-text", IsInputGroupLabel) @@ -54,7 +56,7 @@ public partial class BootstrapInputGroupLabel private bool IsInputGroupLabel => InputGroup != null; /// - /// OnParametersSet 方法 + /// /// protected override void OnParametersSet() { @@ -65,4 +67,26 @@ protected override void OnParametersSet() DisplayText ??= FieldIdentifier?.GetDisplayName(); } } + + /// + /// + /// + /// + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.OpenElement(0, TagName); + builder.AddMultipleAttributes(1, AdditionalAttributes); + builder.AddAttribute(2, "class", ClassString); + builder.AddAttribute(3, "style", StyleString); + builder.AddAttribute(4, "required", Required); + if (ChildContent != null) + { + builder.AddContent(5, ChildContent); + } + else + { + builder.AddContent(6, DisplayText); + } + builder.CloseElement(); + } } diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor deleted file mode 100644 index c616b00fcd9..00000000000 --- a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor +++ /dev/null @@ -1,13 +0,0 @@ -@namespace BootstrapBlazor.Components -@inherits DisplayBase - - - @if (ChildContent != null) - { - @ChildContent - } - else - { - @DisplayText - } - From c0fe15f76f591e14f335718ee45d1dc54079c6f2 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 5 Aug 2025 22:25:29 +0800 Subject: [PATCH 02/10] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=20LinkButt?= =?UTF-8?q?on=20=E7=A7=BB=E9=99=A4=20Razor=20=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{LinkButton.razor.cs => LinkButton.cs} | 48 ++++++++++++++++++- .../Components/Button/LinkButton.razor | 18 ------- 2 files changed, 47 insertions(+), 19 deletions(-) rename src/BootstrapBlazor/Components/Button/{LinkButton.razor.cs => LinkButton.cs} (57%) delete mode 100644 src/BootstrapBlazor/Components/Button/LinkButton.razor diff --git a/src/BootstrapBlazor/Components/Button/LinkButton.razor.cs b/src/BootstrapBlazor/Components/Button/LinkButton.cs similarity index 57% rename from src/BootstrapBlazor/Components/Button/LinkButton.razor.cs rename to src/BootstrapBlazor/Components/Button/LinkButton.cs index 9225eb98cdc..8fbb6a94ff8 100644 --- a/src/BootstrapBlazor/Components/Button/LinkButton.razor.cs +++ b/src/BootstrapBlazor/Components/Button/LinkButton.cs @@ -3,12 +3,16 @@ // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone +using Microsoft.AspNetCore.Components.Rendering; +using Microsoft.AspNetCore.Components.Web; +using System; + namespace BootstrapBlazor.Components; /// /// LinkButton 组件 /// -public partial class LinkButton +public sealed class LinkButton : ButtonBase { /// /// 获得/设置 Url 默认为 # @@ -59,6 +63,48 @@ public partial class LinkButton private bool TriggerClick => !IsDisabled || (string.IsNullOrEmpty(Url)); + /// + /// + /// + /// + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.OpenElement(0, TagName); + builder.AddAttribute(1, "class", ClassString); + builder.AddAttribute(2, "href", UrlString); + builder.AddAttribute(3, "target", Target); + builder.AddAttribute(4, "disabled", Disabled); + builder.AddAttribute(5, "aria-disabled", DisabledString); + builder.AddAttribute(6, "tabindex", Tab); + builder.AddAttribute(7, "id", Id); + builder.AddAttribute(8, "role", "button"); + + if (TriggerClick) + { + builder.AddAttribute(9, "onclick", EventCallback.Factory.Create(this, OnClickButton)); + builder.AddEventPreventDefaultAttribute(10, "onclick", Prevent); + builder.AddEventStopPropagationAttribute(11, "onclick", StopPropagation); + } + + if (!string.IsNullOrEmpty(Icon)) + { + builder.AddContent(12, new MarkupString($"")); + } + + if (!string.IsNullOrEmpty(ImageUrl)) + { + builder.AddContent(13, new MarkupString($"\"img\"")); + } + + if (!string.IsNullOrEmpty(Text)) + { + builder.AddContent(14, new MarkupString($"{Text}")); + } + + builder.AddContent(15, ChildContent); + builder.CloseElement(); + } + private async Task OnClickButton() { if (OnClickWithoutRender != null) diff --git a/src/BootstrapBlazor/Components/Button/LinkButton.razor b/src/BootstrapBlazor/Components/Button/LinkButton.razor deleted file mode 100644 index 0032536b39f..00000000000 --- a/src/BootstrapBlazor/Components/Button/LinkButton.razor +++ /dev/null @@ -1,18 +0,0 @@ -@namespace BootstrapBlazor.Components -@inherits ButtonBase - - - @if (!string.IsNullOrEmpty(Icon)) - { - - } - @if (!string.IsNullOrEmpty(ImageUrl)) - { - img - } - @if (!string.IsNullOrEmpty(Text)) - { - @Text - } - @ChildContent - From 81c7c47a2660b33c811cd4f0a0005afeb913ce81 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 5 Aug 2025 23:06:54 +0800 Subject: [PATCH 03/10] =?UTF-8?q?refactor:=20=E7=B2=BE=E7=AE=80=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/ContextMenu/ContextMenu.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/ContextMenu/ContextMenu.razor b/src/BootstrapBlazor/Components/ContextMenu/ContextMenu.razor index ab11b13f27e..64d0b0843ae 100644 --- a/src/BootstrapBlazor/Components/ContextMenu/ContextMenu.razor +++ b/src/BootstrapBlazor/Components/ContextMenu/ContextMenu.razor @@ -16,7 +16,7 @@ else if (context is ContextMenuItem item) { var disabled = GetItemTriggerClick(item); - @item.Text From da15e6d10e2742006e554f7bf5d8ee5d1c337361 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 5 Aug 2025 23:12:41 +0800 Subject: [PATCH 04/10] =?UTF-8?q?refactor:=20=E4=BD=BF=E7=94=A8=E5=8E=9F?= =?UTF-8?q?=E7=94=9F=E5=85=83=E7=B4=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/DateTimePicker/DatePickerBody.razor | 4 ++-- src/BootstrapBlazor/Components/Select/MultiSelect.razor | 6 +++--- .../Components/SelectGeneric/MultiSelectGeneric.razor | 6 +++--- src/BootstrapBlazor/Components/Upload/CardUpload.razor | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor b/src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor index da506968ab3..d28df051369 100644 --- a/src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor +++ b/src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor @@ -38,8 +38,8 @@ }
- @YearString - @MonthString + @YearString + @MonthString @if (IsDateTimeMode) { @CurrentTime.ToString(TimeFormat) diff --git a/src/BootstrapBlazor/Components/Select/MultiSelect.razor b/src/BootstrapBlazor/Components/Select/MultiSelect.razor index 7b3edeb05e6..07d68f2a590 100644 --- a/src/BootstrapBlazor/Components/Select/MultiSelect.razor +++ b/src/BootstrapBlazor/Components/Select/MultiSelect.razor @@ -67,9 +67,9 @@
@if (ShowDefaultButtons) { - @SelectAllText - @ReverseSelectText - @ClearText + + + } @ButtonTemplate
diff --git a/src/BootstrapBlazor/Components/SelectGeneric/MultiSelectGeneric.razor b/src/BootstrapBlazor/Components/SelectGeneric/MultiSelectGeneric.razor index 19d7c1eb1b4..e4bee4b6d88 100644 --- a/src/BootstrapBlazor/Components/SelectGeneric/MultiSelectGeneric.razor +++ b/src/BootstrapBlazor/Components/SelectGeneric/MultiSelectGeneric.razor @@ -60,9 +60,9 @@
@if (ShowDefaultButtons) { - @SelectAllText - @ReverseSelectText - @ClearText + + + } @ButtonTemplate
diff --git a/src/BootstrapBlazor/Components/Upload/CardUpload.razor b/src/BootstrapBlazor/Components/Upload/CardUpload.razor index 3aa7988b128..1786b7da5c3 100644 --- a/src/BootstrapBlazor/Components/Upload/CardUpload.razor +++ b/src/BootstrapBlazor/Components/Upload/CardUpload.razor @@ -53,11 +53,11 @@
@if (ShowDeleteButton) { - + } @if (GetShowProgress(item)) From bea469b1b69c301c155e7a6c286d0b5dc9e358e5 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 6 Aug 2025 08:40:07 +0800 Subject: [PATCH 05/10] =?UTF-8?q?Revert=20"refactor:=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E7=BB=84=E4=BB=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20@onclick=20=E5=86=99=E6=B3=95"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit c81d0a9f8c08cfa5ddb845f1e81f5447001fe09f. --- .../Input/BootstrapInputGroupLabel.razor | 13 +++++++++ ...l.cs => BootstrapInputGroupLabel.razor.cs} | 28 ++----------------- 2 files changed, 15 insertions(+), 26 deletions(-) create mode 100644 src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor rename src/BootstrapBlazor/Components/Input/{BootstrapInputGroupLabel.cs => BootstrapInputGroupLabel.razor.cs} (72%) diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor new file mode 100644 index 00000000000..c616b00fcd9 --- /dev/null +++ b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor @@ -0,0 +1,13 @@ +@namespace BootstrapBlazor.Components +@inherits DisplayBase + + + @if (ChildContent != null) + { + @ChildContent + } + else + { + @DisplayText + } + diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs similarity index 72% rename from src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs rename to src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs index 3835400b38c..8b1cdf0d3bf 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs +++ b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs @@ -3,14 +3,12 @@ // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone -using Microsoft.AspNetCore.Components.Rendering; - namespace BootstrapBlazor.Components; /// /// BootstrapInputGroupLabel 组件 /// -public sealed class BootstrapInputGroupLabel : DisplayBase +public partial class BootstrapInputGroupLabel { private string? ClassString => CssBuilder.Default() .AddClass("input-group-text", IsInputGroupLabel) @@ -56,7 +54,7 @@ public sealed class BootstrapInputGroupLabel : DisplayBase private bool IsInputGroupLabel => InputGroup != null; /// - /// + /// OnParametersSet 方法 /// protected override void OnParametersSet() { @@ -67,26 +65,4 @@ protected override void OnParametersSet() DisplayText ??= FieldIdentifier?.GetDisplayName(); } } - - /// - /// - /// - /// - protected override void BuildRenderTree(RenderTreeBuilder builder) - { - builder.OpenElement(0, TagName); - builder.AddMultipleAttributes(1, AdditionalAttributes); - builder.AddAttribute(2, "class", ClassString); - builder.AddAttribute(3, "style", StyleString); - builder.AddAttribute(4, "required", Required); - if (ChildContent != null) - { - builder.AddContent(5, ChildContent); - } - else - { - builder.AddContent(6, DisplayText); - } - builder.CloseElement(); - } } From eda3079d22985ce059cc1651de19ea3074a674ce Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 6 Aug 2025 08:40:36 +0800 Subject: [PATCH 06/10] =?UTF-8?q?Reapply=20"refactor:=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E7=BB=84=E4=BB=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20@onclick=20=E5=86=99=E6=B3=95"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit bea469b1b69c301c155e7a6c286d0b5dc9e358e5. --- ...l.razor.cs => BootstrapInputGroupLabel.cs} | 28 +++++++++++++++++-- .../Input/BootstrapInputGroupLabel.razor | 13 --------- 2 files changed, 26 insertions(+), 15 deletions(-) rename src/BootstrapBlazor/Components/Input/{BootstrapInputGroupLabel.razor.cs => BootstrapInputGroupLabel.cs} (72%) delete mode 100644 src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs similarity index 72% rename from src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs rename to src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs index 8b1cdf0d3bf..3835400b38c 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor.cs +++ b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs @@ -3,12 +3,14 @@ // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone +using Microsoft.AspNetCore.Components.Rendering; + namespace BootstrapBlazor.Components; /// /// BootstrapInputGroupLabel 组件 /// -public partial class BootstrapInputGroupLabel +public sealed class BootstrapInputGroupLabel : DisplayBase { private string? ClassString => CssBuilder.Default() .AddClass("input-group-text", IsInputGroupLabel) @@ -54,7 +56,7 @@ public partial class BootstrapInputGroupLabel private bool IsInputGroupLabel => InputGroup != null; /// - /// OnParametersSet 方法 + /// /// protected override void OnParametersSet() { @@ -65,4 +67,26 @@ protected override void OnParametersSet() DisplayText ??= FieldIdentifier?.GetDisplayName(); } } + + /// + /// + /// + /// + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.OpenElement(0, TagName); + builder.AddMultipleAttributes(1, AdditionalAttributes); + builder.AddAttribute(2, "class", ClassString); + builder.AddAttribute(3, "style", StyleString); + builder.AddAttribute(4, "required", Required); + if (ChildContent != null) + { + builder.AddContent(5, ChildContent); + } + else + { + builder.AddContent(6, DisplayText); + } + builder.CloseElement(); + } } diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor deleted file mode 100644 index c616b00fcd9..00000000000 --- a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.razor +++ /dev/null @@ -1,13 +0,0 @@ -@namespace BootstrapBlazor.Components -@inherits DisplayBase - - - @if (ChildContent != null) - { - @ChildContent - } - else - { - @DisplayText - } - From d8d2e7f9737fe83ae34ea5572a64f5aa753b388c Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 6 Aug 2025 08:47:36 +0800 Subject: [PATCH 07/10] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20AdditionalAt?= =?UTF-8?q?tributes=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Button/LinkButton.cs | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/BootstrapBlazor/Components/Button/LinkButton.cs b/src/BootstrapBlazor/Components/Button/LinkButton.cs index 8fbb6a94ff8..c28b59bdcfb 100644 --- a/src/BootstrapBlazor/Components/Button/LinkButton.cs +++ b/src/BootstrapBlazor/Components/Button/LinkButton.cs @@ -70,38 +70,39 @@ public sealed class LinkButton : ButtonBase protected override void BuildRenderTree(RenderTreeBuilder builder) { builder.OpenElement(0, TagName); - builder.AddAttribute(1, "class", ClassString); - builder.AddAttribute(2, "href", UrlString); - builder.AddAttribute(3, "target", Target); - builder.AddAttribute(4, "disabled", Disabled); - builder.AddAttribute(5, "aria-disabled", DisabledString); - builder.AddAttribute(6, "tabindex", Tab); - builder.AddAttribute(7, "id", Id); - builder.AddAttribute(8, "role", "button"); + builder.AddAttribute(10, "class", ClassString); + builder.AddAttribute(20, "href", UrlString); + builder.AddAttribute(30, "target", Target); + builder.AddAttribute(40, "disabled", Disabled); + builder.AddAttribute(50, "aria-disabled", DisabledString); + builder.AddAttribute(60, "tabindex", Tab); + builder.AddAttribute(70, "id", Id); + builder.AddAttribute(80, "role", "button"); + builder.AddMultipleAttributes(90, AdditionalAttributes); if (TriggerClick) { - builder.AddAttribute(9, "onclick", EventCallback.Factory.Create(this, OnClickButton)); + builder.AddAttribute(100, "onclick", EventCallback.Factory.Create(this, OnClickButton)); builder.AddEventPreventDefaultAttribute(10, "onclick", Prevent); builder.AddEventStopPropagationAttribute(11, "onclick", StopPropagation); } if (!string.IsNullOrEmpty(Icon)) { - builder.AddContent(12, new MarkupString($"")); + builder.AddContent(110, new MarkupString($"")); } if (!string.IsNullOrEmpty(ImageUrl)) { - builder.AddContent(13, new MarkupString($"\"img\"")); + builder.AddContent(120, new MarkupString($"\"img\"")); } if (!string.IsNullOrEmpty(Text)) { - builder.AddContent(14, new MarkupString($"{Text}")); + builder.AddContent(130, new MarkupString($"{Text}")); } - builder.AddContent(15, ChildContent); + builder.AddContent(140, ChildContent); builder.CloseElement(); } From 0256d428e26427cde088494384ddb3debec34ec0 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 6 Aug 2025 08:48:52 +0800 Subject: [PATCH 08/10] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E5=BA=8F?= =?UTF-8?q?=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Input/BootstrapInputGroupLabel.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs index 3835400b38c..b85fe8a7ef5 100644 --- a/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs +++ b/src/BootstrapBlazor/Components/Input/BootstrapInputGroupLabel.cs @@ -75,17 +75,17 @@ protected override void OnParametersSet() protected override void BuildRenderTree(RenderTreeBuilder builder) { builder.OpenElement(0, TagName); - builder.AddMultipleAttributes(1, AdditionalAttributes); - builder.AddAttribute(2, "class", ClassString); - builder.AddAttribute(3, "style", StyleString); - builder.AddAttribute(4, "required", Required); + builder.AddMultipleAttributes(10, AdditionalAttributes); + builder.AddAttribute(20, "class", ClassString); + builder.AddAttribute(30, "style", StyleString); + builder.AddAttribute(40, "required", Required); if (ChildContent != null) { - builder.AddContent(5, ChildContent); + builder.AddContent(50, ChildContent); } else { - builder.AddContent(6, DisplayText); + builder.AddContent(60, DisplayText); } builder.CloseElement(); } From 15aafd3087b5cb9001300ccbe8b889fdf110ea77 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 6 Aug 2025 09:07:21 +0800 Subject: [PATCH 09/10] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=20AddImage?= =?UTF-8?q?=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Button/LinkButton.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Button/LinkButton.cs b/src/BootstrapBlazor/Components/Button/LinkButton.cs index c28b59bdcfb..131773ec00c 100644 --- a/src/BootstrapBlazor/Components/Button/LinkButton.cs +++ b/src/BootstrapBlazor/Components/Button/LinkButton.cs @@ -94,7 +94,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder) if (!string.IsNullOrEmpty(ImageUrl)) { - builder.AddContent(120, new MarkupString($"\"img\"")); + builder.AddContent(120, AddImage()); } if (!string.IsNullOrEmpty(Text)) @@ -106,12 +106,25 @@ protected override void BuildRenderTree(RenderTreeBuilder builder) builder.CloseElement(); } + private RenderFragment AddImage() => builder => + { + builder.OpenElement(0, "img"); + builder.AddAttribute(10, "src", ImageUrl); + builder.AddAttribute(20, "alt", "img"); + if (!string.IsNullOrEmpty(ImageCss)) + { + builder.AddAttribute(30, "class", ImageCss); + } + builder.CloseElement(); + }; + private async Task OnClickButton() { if (OnClickWithoutRender != null) { await OnClickWithoutRender(); } + if (OnClick.HasDelegate) { await OnClick.InvokeAsync(); From df58a5db776dfea9bcdbb6d6431e82994ba6fb09 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 6 Aug 2025 09:11:42 +0800 Subject: [PATCH 10/10] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Button/LinkButton.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BootstrapBlazor/Components/Button/LinkButton.cs b/src/BootstrapBlazor/Components/Button/LinkButton.cs index 131773ec00c..7538ff1a519 100644 --- a/src/BootstrapBlazor/Components/Button/LinkButton.cs +++ b/src/BootstrapBlazor/Components/Button/LinkButton.cs @@ -109,12 +109,12 @@ protected override void BuildRenderTree(RenderTreeBuilder builder) private RenderFragment AddImage() => builder => { builder.OpenElement(0, "img"); - builder.AddAttribute(10, "src", ImageUrl); - builder.AddAttribute(20, "alt", "img"); + builder.AddAttribute(10, "alt", "img"); if (!string.IsNullOrEmpty(ImageCss)) { - builder.AddAttribute(30, "class", ImageCss); + builder.AddAttribute(20, "class", ImageCss); } + builder.AddAttribute(30, "src", ImageUrl); builder.CloseElement(); };