Skip to content

Commit 6f3e917

Browse files
authored
feat(Layout): add style support ShowTabInHeader parameter (#5773)
* refactor: 恢复样式 * refactor: 调整火柴棍出现逻辑 * refactor: 更新 Tab 支持 ShowTabInHeader 切换逻辑 * refactor: 更新样式 * style: 增加兼容模板的顶栏标签页样式 * chore: bump version 9.5.2
1 parent 208d440 commit 6f3e917

File tree

5 files changed

+57
-10
lines changed

5 files changed

+57
-10
lines changed

src/BootstrapBlazor/BootstrapBlazor.csproj

+1-1
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.5.1</Version>
4+
<Version>9.5.2</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Layout/Layout.razor.scss

+44-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949

5050
.layout-main {
5151
min-height: calc(var(--bb-layout-height) - var(--bb-layout-header-height) - var(--bb-layout-footer-height));
52+
53+
> .tabs {
54+
margin: -1rem;
55+
border: none;
56+
border-radius: unset;
57+
min-height: calc(100% + 2rem);
58+
}
5259
}
5360
}
5461

@@ -184,6 +191,42 @@
184191
transition: transform .3s linear;
185192
}
186193
}
194+
195+
> .tabs {
196+
height: 100%;
197+
display: flex;
198+
justify-content: flex-end;
199+
flex: 1;
200+
width: 1%;
201+
min-width: 0;
202+
margin-bottom: -2px;
203+
}
204+
205+
> .tabs.tabs-chrome {
206+
.tabs-header {
207+
--bb-tabs-item-height: 47px;
208+
--bb-tabs-header-color: #fff;
209+
--bb-tabs-chrome-item-height: 43px;
210+
--bs-border-color: var(--bb-layout-headerbar-background);
211+
--bb-tabs-header-bg-color: var(--bb-layout-headerbar-background);
212+
213+
.tabs-item-close:hover {
214+
background-color: transparent;
215+
}
216+
217+
.tabs-item-wrap:not(.active) .tabs-item {
218+
color: var(--bb-tabs-header-color);
219+
}
220+
221+
.tabs-nav-toolbar .btn {
222+
--bs-btn-color: var(--bb-tabs-header-color);
223+
}
224+
225+
.nav-link-bar {
226+
--bs-body-color: var(--bb-tabs-header-color);
227+
}
228+
}
229+
}
187230
}
188231

189232
&:not(.has-footer) {
@@ -229,7 +272,7 @@
229272

230273
&.is-fixed-tab {
231274
.layout-menu,
232-
.tabs {
275+
.layout-main > .tabs {
233276
height: calc(var(--bb-layout-height) - var(--bb-layout-header-height) - var(--bb-layout-footer-height));
234277

235278
.tabs-body {

src/BootstrapBlazor/Components/Tab/Tab.razor

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ else
6565
<RenderTemplate>
6666
@RenderTabList()
6767
</RenderTemplate>
68-
@if (!IsCard && !IsBorderCard && ShowActiveBar)
68+
@if (!IsCard && !IsBorderCard && ShowActiveBar && TabStyle == TabStyle.Default)
6969
{
7070
<div class="tabs-active-bar"></div>
7171
}

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,6 @@ protected override void OnInitialized()
481481
base.OnInitialized();
482482

483483
ErrorLogger?.Register(this);
484-
485-
if (Layout is { ShowTabInHeader: true })
486-
{
487-
Layout.RegisterTab(this);
488-
}
489484
}
490485

491486
/// <summary>
@@ -499,6 +494,15 @@ protected override void OnParametersSet()
499494
IsBorderCard = true;
500495
}
501496

497+
if (Layout is { ShowTabInHeader: true })
498+
{
499+
Layout.RegisterTab(this);
500+
}
501+
else
502+
{
503+
TabHeader = null;
504+
}
505+
502506
CloseOtherTabsText ??= Localizer[nameof(CloseOtherTabsText)];
503507
CloseAllTabsText ??= Localizer[nameof(CloseAllTabsText)];
504508
CloseCurrentTabText ??= Localizer[nameof(CloseCurrentTabText)];

src/BootstrapBlazor/Components/Tab/Tab.razor.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@
494494

495495
.tabs-chrome > .tabs-header,
496496
.tabs-capsule > .tabs-header {
497-
--bb-tabs-header-height: 36px;
497+
--bb-tabs-chrome-item-height: 36px;
498498
--bb-tabs-header-bg-color: var(--bs-border-color);
499499
--bb-tabs-item-body-border-radius: 14.5px;
500500
--bb-tabs-item-body-padding: 4px 10px;
@@ -637,7 +637,7 @@
637637
border: none !important;
638638
border-top-left-radius: 10px;
639639
border-top-right-radius: 10px;
640-
height: var(--bb-tabs-header-height) !important;
640+
height: var(--bb-tabs-chrome-item-height) !important;
641641

642642
.tabs-item-body {
643643
margin-bottom: var(--bb-tabs-item-body-margin-bottom);

0 commit comments

Comments
 (0)