Skip to content

Commit 49adb87

Browse files
authored
feat(Tab): add BeforeNavigatorTemplate/AfterNavigatorTemplate parameter (#5394)
* feat: 增加前后模板 * chore: bump version 9.3.1-beta21 * test: 增加单元测试
1 parent 4706145 commit 49adb87

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-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.3.1-beta19</Version>
4+
<Version>9.3.1-beta21</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Tab/Tab.razor

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ else
1111
<div @attributes="@AdditionalAttributes" id="@Id" class="@ClassString" style="@StyleString">
1212
<div class="tabs-header">
1313
<div class="@WrapClassString">
14+
@if (BeforeNavigatorTemplate != null)
15+
{
16+
@BeforeNavigatorTemplate
17+
}
1418
@if (ShowNavigatorButtons)
1519
{
1620
<div class="nav-link-bar left" @onclick="@ClickPrevTab"><i class="@PreviousIcon"></i></div>
@@ -106,6 +110,10 @@ else
106110
<div class="dropdown-item" @onclick="@OnClickCloseAllTabs"><span>@CloseAllTabsText</span></div>
107111
</div>
108112
}
113+
@if (AfterNavigatorTemplate != null)
114+
{
115+
@AfterNavigatorTemplate
116+
}
109117
</div>
110118
</div>
111119
<div class="tabs-body">

src/BootstrapBlazor/Components/Tab/Tab.razor.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,20 @@ public partial class Tab : IHandlerException
226226
[Parameter]
227227
public RenderFragment? ButtonTemplate { get; set; }
228228

229+
/// <summary>
230+
/// 获得/设置 标签页前置模板 默认 null
231+
/// <para>在向前移动标签页按钮前</para>
232+
/// </summary>
233+
[Parameter]
234+
public RenderFragment? BeforeNavigatorTemplate { get; set; }
235+
236+
/// <summary>
237+
/// 获得/设置 标签页后置模板 默认 null
238+
/// <para>在向后移动标签页按钮前</para>
239+
/// </summary>
240+
[Parameter]
241+
public RenderFragment? AfterNavigatorTemplate { get; set; }
242+
229243
/// <summary>
230244
/// 获得/设置 上一个标签图标
231245
/// </summary>

test/UnitTest/Components/TabTest.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,27 @@ public async Task FullScreen_Ok()
877877
await cut.InvokeAsync(() => button.Click());
878878
}
879879

880+
[Fact]
881+
public void BeforeNavigatorTemplate_Ok()
882+
{
883+
var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
884+
{
885+
pb.AddChildContent<Tab>(pb =>
886+
{
887+
pb.Add(a => a.BeforeNavigatorTemplate, builder => builder.AddContent(0, "before-navigator-template"));
888+
pb.Add(a => a.AfterNavigatorTemplate, builder => builder.AddContent(0, "after-navigator-template"));
889+
pb.AddChildContent<TabItem>(pb =>
890+
{
891+
pb.Add(a => a.ShowFullScreen, true);
892+
pb.Add(a => a.Text, "Text1");
893+
pb.Add(a => a.ChildContent, builder => builder.AddContent(0, "Test1"));
894+
});
895+
});
896+
});
897+
cut.Contains("before-navigator-template");
898+
cut.Contains("after-navigator-template");
899+
}
900+
880901
class DisableTabItemButton : ComponentBase
881902
{
882903
[CascadingParameter, NotNull]

0 commit comments

Comments
 (0)