Skip to content

Commit e339197

Browse files
authored
feat(Tab): add ShowNavigatorButtons parameter (#5386)
* chore: 更新项目格式 * feat(Tab): add ShowNavigatorButtons parameter * test: 增加单元测试
1 parent 8417ac5 commit e339197

File tree

4 files changed

+94
-2
lines changed

4 files changed

+94
-2
lines changed

BootstrapBlazor.slnx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<Solution>
2+
<Folder Name="/configuration/">
3+
<File Path=".editorconfig" />
4+
<File Path=".gitignore" />
5+
<File Path="exclusion.dic" />
6+
<File Path="Framework.props" />
7+
</Folder>
8+
<Folder Name="/docs/">
9+
<File Path="README.md" />
10+
<File Path="README.zh-CN.md" />
11+
</Folder>
12+
<Folder Name="/localization/">
13+
<File Path="localization/de.json" />
14+
<File Path="localization/es.json" />
15+
<File Path="localization/pt.json" />
16+
<File Path="localization/th-TH.json" />
17+
<File Path="localization/zh-TW.json" />
18+
</Folder>
19+
<Folder Name="/scripts/" />
20+
<Folder Name="/scripts/linux/">
21+
<File Path="scripts/linux/ba.blazor.service" />
22+
<File Path="scripts/linux/deploy-blazor.sh" />
23+
<File Path="scripts/linux/deploy.sh" />
24+
<File Path="scripts/linux/nginx.conf" />
25+
<File Path="scripts/linux/remove.sh" />
26+
</Folder>
27+
<Folder Name="/scripts/linux/cert/">
28+
<File Path="scripts/linux/cert/blazor.zone.cer" />
29+
<File Path="scripts/linux/cert/blazor.zone.key" />
30+
<File Path="scripts/linux/cert/www.blazor.zone.cer" />
31+
<File Path="scripts/linux/cert/www.blazor.zone.key" />
32+
</Folder>
33+
<Folder Name="/scripts/wasm/">
34+
<File Path="scripts/wasm/sync.cmd" />
35+
<File Path="scripts/wasm/sync.sh" />
36+
</Folder>
37+
<Folder Name="/scripts/windows/">
38+
<File Path="scripts/windows/pack.cmd" />
39+
<File Path="scripts/windows/push.cmd" />
40+
<File Path="scripts/windows/push.ps1" />
41+
</Folder>
42+
<Folder Name="/src/">
43+
<Project Path="src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj" />
44+
<Project Path="src/BootstrapBlazor/BootstrapBlazor.csproj" />
45+
</Folder>
46+
<Folder Name="/test/">
47+
<Project Path="test/UniTest.Sass/UniTest.Sass.csproj" />
48+
<Project Path="test/UnitTest.Localization/UnitTest.Localization.csproj" />
49+
<Project Path="test/UnitTest/UnitTest.csproj" />
50+
<Project Path="test/UnitTestDocs/UnitTestDocs.csproj" />
51+
</Folder>
52+
<Folder Name="/tools/">
53+
<Project Path="tools/Benchmarks/UnitTest.Benchmarks.csproj" />
54+
</Folder>
55+
</Solution>

src/BootstrapBlazor/Components/Tab/Tab.razor

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ else
1111
<div @attributes="@AdditionalAttributes" id="@Id" class="@ClassString" style="@StyleString">
1212
<div class="tabs-header">
1313
<div class="@WrapClassString">
14-
<div class="nav-link-bar left" @onclick="@ClickPrevTab"><i class="@PreviousIcon"></i></div>
14+
@if (ShowNavigatorButtons)
15+
{
16+
<div class="nav-link-bar left" @onclick="@ClickPrevTab"><i class="@PreviousIcon"></i></div>
17+
}
1518
<div class="tabs-nav-scroll">
1619
<div role="tablist" class="tabs-nav">
1720
<CascadingValue Value="this" IsFixed="true">
@@ -88,7 +91,10 @@ else
8891
{
8992
@ButtonTemplate
9093
}
91-
<div class="nav-link-bar right" @onclick="@ClickNextTab"><i class="@NextIcon"></i></div>
94+
@if (ShowNavigatorButtons)
95+
{
96+
<div class="nav-link-bar right" @onclick="@ClickNextTab"><i class="@NextIcon"></i></div>
97+
}
9298
@if (ShouldShowExtendButtons())
9399
{
94100
<div class="nav-link-bar dropdown dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ public partial class Tab : IHandlerException
125125
[Parameter]
126126
public bool ShowExtendButtons { get; set; }
127127

128+
/// <summary>
129+
/// 获得/设置 是否显示导航按钮 默认为 true 显示
130+
/// </summary>
131+
[Parameter]
132+
public bool ShowNavigatorButtons { get; set; } = true;
133+
128134
/// <summary>
129135
/// 获得/设置 点击 TabItem 时是否自动导航 默认为 false 不导航
130136
/// </summary>

test/UnitTest/Components/TabTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,31 @@ public void ButtonTemplate_Ok()
630630
cut.Contains("<div>test-button</div>");
631631
}
632632

633+
[Fact]
634+
public void ShowNavigatorButtons_Ok()
635+
{
636+
var cut = Context.RenderComponent<Tab>(pb =>
637+
{
638+
pb.Add(a => a.AdditionalAssemblies, new Assembly[] { GetType().Assembly });
639+
pb.Add(a => a.ShowNavigatorButtons, true);
640+
pb.AddChildContent<TabItem>(pb =>
641+
{
642+
pb.Add(a => a.Text, "Tab1");
643+
pb.Add(a => a.Url, "/Cat");
644+
});
645+
});
646+
647+
var links = cut.FindAll(".nav-link-bar");
648+
Assert.Equal(2, links.Count);
649+
650+
cut.SetParametersAndRender(pb =>
651+
{
652+
pb.Add(a => a.ShowNavigatorButtons, false);
653+
});
654+
links = cut.FindAll(".nav-link-bar");
655+
Assert.Empty(links);
656+
}
657+
633658
[Fact]
634659
public void Text_Ok()
635660
{

0 commit comments

Comments
 (0)