Skip to content

Commit 94c27d8

Browse files
feat(ModalDialog): add FooterContentTemplate parameter (#5947)
* feat: 增加 FooterContentTemplate 参数 * style: 增加 modal-footer-content 样式 * test: 增加单元测试 * chore: bump version 9.6.1-beta01 Co-Authored-By: FelixYe <[email protected]> --------- Co-authored-by: FelixYe <[email protected]>
1 parent a6e14bd commit 94c27d8

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.6.1-beta02</Version>
4+
<Version>9.6.1-beta01</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Modal/Modal.razor.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@
2121

2222
.modal-footer {
2323
padding: 0.5rem 1rem;
24+
25+
.modal-footer-content {
26+
flex-grow: 1;
27+
min-width: 0;
28+
width: 1%;
29+
white-space: nowrap;
30+
overflow: hidden;
31+
display: flex;
32+
align-items: center;
33+
justify-content: flex-start;
34+
margin-inline-end: 1rem;
35+
}
2436
}
2537

2638
.modal-footer > * {

src/BootstrapBlazor/Components/Modal/ModalDialog.razor

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
@if (ShowFooter)
5151
{
5252
<div class="modal-footer">
53+
@if (FooterContentTemplate != null)
54+
{
55+
<div class="modal-footer-content">
56+
@FooterContentTemplate
57+
</div>
58+
}
5359
@if (ShowCloseButton)
5460
{
5561
<Button Color="Color.Secondary" Text="@CloseButtonText" Icon="@CloseButtonIcon" OnClickWithoutRender="OnClickCloseAsync"></Button>

src/BootstrapBlazor/Components/Modal/ModalDialog.razor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ public partial class ModalDialog : IHandlerException
200200
[Parameter]
201201
public RenderFragment? FooterTemplate { get; set; }
202202

203+
/// <summary>
204+
/// Gets or sets the footer content template. Default is null.
205+
/// </summary>
206+
[Parameter]
207+
public RenderFragment? FooterContentTemplate { get; set; }
208+
203209
/// <summary>
204210
/// 获得/设置 ModalHeader 组件
205211
/// </summary>

test/UnitTest/Components/ModalDialogTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public void BodyContext_Ok()
166166
{
167167
pb.AddChildContent<ModalDialog>(pb =>
168168
{
169+
pb.Add(d => d.FooterContentTemplate, builder => builder.AddContent(0, "footer-content-template"));
169170
pb.Add(d => d.BodyContext, new Foo() { Name = "Test_BodyContext" });
170171
pb.Add(d => d.BodyTemplate, BootstrapDynamicComponent.CreateComponent<MockModalDialogContentComponent>().Render());
171172
});
@@ -174,6 +175,7 @@ public void BodyContext_Ok()
174175
var content = cut.FindComponent<MockModalDialogContentComponent>().Instance;
175176
var f = content.Context as Foo;
176177
Assert.Equal("Test_BodyContext", f!.Name);
178+
cut.Contains("footer-content-template");
177179
}
178180

179181
[Fact]

0 commit comments

Comments
 (0)