Skip to content

Commit 2b1ab85

Browse files
authored
feat(Tab): add ShowActiveBar parameter (#5388)
* feat(Tab): add ShowActiveBar parameter * test: 增加单元测试 * doc: 更新注释 * doc: 增加新参数说明文档
1 parent e339197 commit 2b1ab85

File tree

6 files changed

+50
-3
lines changed

6 files changed

+50
-3
lines changed

src/BootstrapBlazor.Server/Components/Samples/Tabs.razor.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,22 @@ private AttributeItem[] GetAttributes() =>
226226
DefaultValue = "false"
227227
},
228228
new()
229+
{
230+
Name = "ShowExtendButtons",
231+
Description = Localizer["TabAttrShowNavigatorButtons"].Value,
232+
Type = "boolean",
233+
ValueList = "true|false",
234+
DefaultValue = "true"
235+
},
236+
new()
237+
{
238+
Name = "ShowExtendButtons",
239+
Description = Localizer["TabAttrShowActiveBar"].Value,
240+
Type = "boolean",
241+
ValueList = "true|false",
242+
DefaultValue = "true"
243+
},
244+
new()
229245
{
230246
Name = "ClickTabToNavigation",
231247
Description = Localizer["TabAtt6ClickTabToNavigation"].Value,
@@ -369,7 +385,6 @@ private AttributeItem[] GetAttributes() =>
369385
/// <returns></returns>
370386
private MethodItem[] GetMethods() =>
371387
[
372-
373388
new MethodItem()
374389
{
375390
Name = "AddTab",

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,6 +2085,8 @@
20852085
"TabAtt3IsOnlyRenderActiveTab": "Whether to render only Active labels",
20862086
"TabAtt4ShowClose": "Whether to display the close button",
20872087
"TabAtt5ShowExtendButtons": "Whether to display the extension button",
2088+
"TabAttShowNavigatorButtons": "Whether to display the previous and next navigation buttons",
2089+
"TabAttShowActiveBar": "Whether to display active bar",
20882090
"TabAtt6ClickTabToNavigation": "Whether to navigate when you click on the title",
20892091
"TabAtt7Placement": "Set the label position",
20902092
"TabAtt8Height": "Set the label height",

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,6 +2085,8 @@
20852085
"TabAtt3IsOnlyRenderActiveTab": "是否仅渲染 Active 标签",
20862086
"TabAtt4ShowClose": "是否显示关闭按钮",
20872087
"TabAtt5ShowExtendButtons": "是否显示扩展按钮",
2088+
"TabAttShowNavigatorButtons": "是否显示前后导航按钮",
2089+
"TabAttShowActiveBar": "是否显示活动标签",
20882090
"TabAtt6ClickTabToNavigation": "点击标题时是否导航",
20892091
"TabAtt7Placement": "设置标签位置",
20902092
"TabAtt8Height": "设置标签高度",

src/BootstrapBlazor/Components/Tab/Tab.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ else
8181
<div class="tabs-item-fix"></div>
8282
}
8383
</RenderTemplate>
84-
@if (!IsCard && !IsBorderCard)
84+
@if (!IsCard && !IsBorderCard && ShowActiveBar)
8585
{
8686
<div class="tabs-active-bar"></div>
8787
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,17 @@ public partial class Tab : IHandlerException
126126
public bool ShowExtendButtons { get; set; }
127127

128128
/// <summary>
129-
/// 获得/设置 是否显示导航按钮 默认为 true 显示
129+
/// 获得/设置 是否显示前后导航按钮 默认为 true 显示
130130
/// </summary>
131131
[Parameter]
132132
public bool ShowNavigatorButtons { get; set; } = true;
133133

134+
/// <summary>
135+
/// 获得/设置 是否显示活动标签 默认为 true 显示
136+
/// </summary>
137+
[Parameter]
138+
public bool ShowActiveBar { get; set; } = true;
139+
134140
/// <summary>
135141
/// 获得/设置 点击 TabItem 时是否自动导航 默认为 false 不导航
136142
/// </summary>

test/UnitTest/Components/TabTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,28 @@ public void ShowNavigatorButtons_Ok()
655655
Assert.Empty(links);
656656
}
657657

658+
[Fact]
659+
public void ShowActiveBar_Ok()
660+
{
661+
var cut = Context.RenderComponent<Tab>(pb =>
662+
{
663+
pb.Add(a => a.AdditionalAssemblies, new Assembly[] { GetType().Assembly });
664+
pb.Add(a => a.ShowActiveBar, true);
665+
pb.AddChildContent<TabItem>(pb =>
666+
{
667+
pb.Add(a => a.Text, "Tab1");
668+
pb.Add(a => a.Url, "/Cat");
669+
});
670+
});
671+
cut.Contains("<div class=\"tabs-active-bar\"></div>");
672+
673+
cut.SetParametersAndRender(pb =>
674+
{
675+
pb.Add(a => a.ShowActiveBar, false);
676+
});
677+
cut.DoesNotContain("<div class=\"tabs-active-bar\"></div>");
678+
}
679+
658680
[Fact]
659681
public void Text_Ok()
660682
{

0 commit comments

Comments
 (0)