Skip to content

Commit 9a1b5cc

Browse files
authored
feat(Layout): add IsFixedTabHeader parameter (#4668)
* doc: 代码格式化 * refactor: 移除空属性 * refactor: 重新设计收起样式 * feat: Layout 组件支持 static 渲染模式 * fix(Widget): 修复报错问题 * chore: bump version 9.0.0-beta03 * style: 移除抽屉 padding 间隙 * refactor: 移除宽度计算样式 * doc: 后台示例更新登录信息栏 * doc: 格式化文档 * refactor: 样式独立文件 * doc: 精简样式 * refactor: 更新 Widget 组件与模板一致 * refactor: 修复调整结构组件状态不正确问题 * refactor: 重构方法提高性能 * refactor: 修复布尔值时不触发 OnStateChanged 回调问题 * refactor: 修复布尔值时不触发 OnStateChanged 回调问题 * test: 增加单元测试 * refactor: 精简代码提高效率 * refactor: 调整右侧边框样式 * chore: bump version 9.0.1-beta01 * doc: 移除 2019 文字 * doc: 移除 2019 文字 * refactor: 更改样式名称 * refactor: 重构侧边栏收起样式 * refactor: 更新 Menu 透明样式 * doc: 更新后台管理样式 * style: 兼容 Menu 组件 * style: 增加响应式布局 * refactor: 重构样式 * wip: 临时移除静态支持 * style: 微调样式 * refactor: 精简样式 * style: 微调 Menu 样式 * refactor: 增加层次 * style: 调整 Title 颜色 * style: 调整收起展开菜单宽度样式 * style: 增加菜单右侧边框线 * doc: 调整文档 * doc: 更新文档链接 * style: 合并样式 * style: 合并样式 * style: 整理 header-bar 样式 * refactor: 重构样式 * style: 层次化样式 * style: 层次化样式 * refactor: 移除 IsPage 参数 * refactor: 移除 static 判断逻辑 * style: 合并 Header 样式 * refactor: 移除侧边栏抽屉 * style: 合并样式 * refactor: 移除 SideWidth=“0” 设置 * refactor: 使用 div 元素渲染按钮 * refactor: 恢复脚本 * refactor: 重构代码 * doc: 移除 IsPage 文档 * doc: 更新开发工具名称 * refactor: 调整层次结构 * refactor: 增加 IsFixedTabHeader 参数 * doc: 后台管理使用固定标签页参数 * test: 增加单元测试 * doc: 增加参数说明 * style: 更新固定标签头样式 * refactor: 增加 Layout 高度设置 * doc: 更新示例 * test: 更新单元测试
1 parent 1aacef5 commit 9a1b5cc

File tree

11 files changed

+88
-44
lines changed

11 files changed

+88
-44
lines changed

src/BootstrapBlazor.Server/Components/Layout/PageLayout.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</HeadContent>
77

88
<CascadingValue Value="this" IsFixed="true">
9-
<Layout IsFullSide="@IsFullSide" IsFixedHeader="@IsFixedHeader" IsFixedFooter="@IsFixedFooter"
9+
<Layout IsPage="true" IsFullSide="@IsFullSide" IsFixedHeader="@IsFixedHeader" IsFixedFooter="@IsFixedFooter" IsFixedTabHeader="IsFixedTabHeader"
1010
ShowFooter="@ShowFooter" ShowGotoTop="true" ShowCollapseBar="true" Menus="@Menus"
1111
UseTabSet="@UseTabSet" TabDefaultUrl="layout-page" AdditionalAssemblies="new[] { GetType().Assembly }" class="@LayoutClassString">
1212
<Header>

src/BootstrapBlazor.Server/Components/Layout/PageLayout.razor.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,10 @@ public sealed partial class PageLayout
1616

1717
private string? LayoutClassString => CssBuilder.Default("layout-demo")
1818
.AddClass(Theme)
19-
.AddClass("is-fixed-tab", IsFixedTab)
2019
.Build();
2120

2221
private IEnumerable<MenuItem>? Menus { get; set; }
2322

24-
/// <summary>
25-
/// 获得/设置 是否固定 TabHeader
26-
/// </summary>
27-
public bool IsFixedTab { get; set; }
28-
2923
/// <summary>
3024
/// 获得/设置 是否固定页头
3125
/// </summary>
@@ -36,6 +30,11 @@ public sealed partial class PageLayout
3630
/// </summary>
3731
public bool IsFixedFooter { get; set; } = true;
3832

33+
/// <summary>
34+
/// 获得/设置 是否固定页脚
35+
/// </summary>
36+
public bool IsFixedTabHeader { get; set; } = false;
37+
3938
/// <summary>
4039
/// 获得/设置 侧边栏是否外置
4140
/// </summary>

src/BootstrapBlazor.Server/Components/Samples/LayoutPages.razor

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636

3737
<div class="page-layout-demo-option">
3838
<p>@Localizer["P20"]</p>
39-
<Checkbox Value="@IsFixedTab" OnStateChanged="@OnTabStateChanged" ShowAfterLabel="true" DisplayText="@Localizer["P21"]" />
40-
<Checkbox Value="@IsFixedHeader" OnStateChanged="@OnHeaderStateChanged" IsDisabled="IsFixedTab" ShowAfterLabel="true" DisplayText="@Localizer["P22"]" class="mx-3" />
41-
<Checkbox Value="@IsFixedFooter" OnStateChanged="@OnFooterStateChanged" IsDisabled="IsFixedTab" ShowAfterLabel="true" DisplayText="@Localizer["P23"]" />
39+
<Checkbox Value="@IsFixedTabHeader" OnStateChanged="@OnTabStateChanged" ShowAfterLabel="true" DisplayText="@Localizer["P21"]" />
40+
<Checkbox Value="@IsFixedHeader" OnStateChanged="@OnHeaderStateChanged" IsDisabled="IsFixedTabHeader" ShowAfterLabel="true" DisplayText="@Localizer["P22"]" class="mx-3" />
41+
<Checkbox Value="@IsFixedFooter" OnStateChanged="@OnFooterStateChanged" IsDisabled="IsFixedTabHeader" ShowAfterLabel="true" DisplayText="@Localizer["P23"]" />
4242
</div>
4343

4444
<div class="page-layout-demo-option">
@@ -60,7 +60,7 @@
6060
<div class="page-layout-demo-option">
6161
<p>@Localizer["P29"]</p>
6262
<div>@Localizer["P30"] <b><TabLink Text="@Localizer["P31"]" Url="layout-page1" Icon="fa-solid fa-font-awesome">@Localizer["P32"]</TabLink></b> @Localizer["P33"]</div>
63-
<div class="mt-2">@Localizer["P34"] <Button Text="@Localizer["P35"]" Icon="fa-solid fa-font-awesome" OnClickWithoutRender="OnNavigation" /></div>
63+
<div class="mt-2">@Localizer["P34"] <Button Text="@Localizer["P35"]" Icon="fa-solid fa-font-awesome" OnClickWithoutRender="OnNavigation" TooltipText="Tooltip" TooltipTrigger="hover" /></div>
6464
</div>
6565
}
6666
</div>

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ public sealed partial class LayoutPages
3131
private bool ShowFooter { get; set; }
3232

3333
/// <summary>
34-
/// 获得/设置 是否固定 TabHeader
34+
/// 获得/设置 是否固定 Header
3535
/// </summary>
36-
private bool IsFixedTab { get; set; }
36+
private bool IsFixedHeader { get; set; }
3737

3838
/// <summary>
39-
/// 获得/设置 是否固定 Header
39+
/// 获得/设置 是否固定标签页 Header
4040
/// </summary>
41-
private bool IsFixedHeader { get; set; }
41+
private bool IsFixedTabHeader { get; set; }
4242

4343
/// <summary>
4444
/// 获得/设置 是否固定页脚
@@ -75,6 +75,7 @@ protected override void OnInitialized()
7575
IsFixedFooter = RootPage.IsFixedFooter;
7676
ShowFooter = RootPage.ShowFooter;
7777
UseTabSet = RootPage.UseTabSet;
78+
IsFixedTabHeader = RootPage.IsFixedTabHeader;
7879

7980
ActiveItem = IsFullSide ? SideBarItems[0] : SideBarItems[1];
8081
}
@@ -88,7 +89,7 @@ private Task OnFooterChanged(bool val)
8889

8990
private Task OnTabStateChanged(CheckboxState state, bool val)
9091
{
91-
IsFixedTab = val;
92+
IsFixedTabHeader = val;
9293
Update();
9394
return Task.CompletedTask;
9495
}
@@ -133,7 +134,7 @@ public void Update()
133134
RootPage.IsFullSide = IsFullSide;
134135
RootPage.IsFixedFooter = IsFixedFooter && ShowFooter;
135136
RootPage.IsFixedHeader = IsFixedHeader;
136-
RootPage.IsFixedTab = IsFixedTab;
137+
RootPage.IsFixedTabHeader = IsFixedTabHeader;
137138
RootPage.ShowFooter = ShowFooter;
138139
RootPage.UseTabSet = UseTabSet;
139140
StateHasChanged();

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ private AttributeItem[] GetAttributes() =>
136136
DefaultValue = "false"
137137
},
138138
new()
139+
{
140+
Name = nameof(BootstrapBlazor.Components.Layout.IsFixedTabHeader),
141+
Description = Localizer["Layouts_IsFixedTabHeader_Description"],
142+
Type = "bool",
143+
ValueList = "true|false",
144+
DefaultValue = "false"
145+
},
146+
new()
139147
{
140148
Name = "AdditionalAssemblies",
141149
Description = Localizer["Layouts_AdditionalAssemblies_Description"],

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,7 @@
14741474
"Layouts_ShowFooter_Description": "Whether to show Footer template",
14751475
"Layouts_ShowGotoTop_Description": "Whether to display the back to top button",
14761476
"Layouts_UseTabSet_Description": "Whether to open multi-label mode",
1477+
"Layouts_IsFixedTabHeader_Description": "Whether to fix the Header of Tabset",
14771478
"Layouts_AdditionalAssemblies_Description": "Collection of additional programs, passed to the Tab component for use",
14781479
"Layouts_OnCollapsed_Description": "Contract expand callback delegate",
14791480
"Layouts_OnClickMenu_Description": "Call back the delegate when the menu item is clicked",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,7 @@
14741474
"Layouts_ShowFooter_Description": "是否显示 Footer 模板",
14751475
"Layouts_ShowGotoTop_Description": "是否显示返回顶端按钮",
14761476
"Layouts_UseTabSet_Description": "是否开启多标签模式",
1477+
"Layouts_IsFixedTabHeader_Description": "是否固定多标签 Header",
14771478
"Layouts_AdditionalAssemblies_Description": "额外程序集合,传递给 Tab 组件使用",
14781479
"Layouts_OnCollapsed_Description": "收缩展开回调委托",
14791480
"Layouts_OnClickMenu_Description": "点击菜单项时回调委托",

src/BootstrapBlazor.Server/wwwroot/css/site.css

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,9 @@ h3, h4, h5 {
7070
}
7171

7272
.layout {
73-
--bb-footer-height: 0px;
7473
--bb-layout-menu-item-hover-bg: var(--bb-primary-color);
7574
}
7675

77-
.layout.has-footer {
78-
--bb-footer-height: 40px;
79-
}
80-
81-
.is-fixed-tab .tabs-body {
82-
height: calc(100vh - var(--bb-layout-header-height) - var(--bb-tabs-item-height) - var(--bb-footer-height));
83-
overflow: auto;
84-
flex: initial;
85-
}
86-
87-
.is-fixed-tab .tabs-body .tabs-body-content {
88-
height: auto;
89-
min-height: 100%;
90-
}
91-
9276
.bb-sub {
9377
margin-top: .25rem;
9478
font-size: 86%;

src/BootstrapBlazor/Components/Layout/Layout.razor.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ public partial class Layout : IHandlerException
108108
/// </summary>
109109
/// <remarks>为真时增加 is-page 样式</remarks>
110110
[Parameter]
111-
[Obsolete("已弃用,直接删除即可;Deprecated Please remove it")]
112-
[ExcludeFromCodeCoverage]
113111
public bool IsPage { get; set; }
114112

115113
/// <summary>
@@ -124,6 +122,12 @@ public partial class Layout : IHandlerException
124122
[Parameter]
125123
public bool UseTabSet { get; set; }
126124

125+
/// <summary>
126+
/// 获得/设置 是否固定多标签 Header 默认 false
127+
/// </summary>
128+
[Parameter]
129+
public bool IsFixedTabHeader { get; set; }
130+
127131
/// <summary>
128132
/// 获得/设置 是否仅渲染 Active 标签
129133
/// </summary>
@@ -236,12 +240,14 @@ public partial class Layout : IHandlerException
236240
.AddClass("has-sidebar", Side != null && IsFullSide)
237241
.AddClass("has-footer", ShowFooter && Footer != null)
238242
.AddClass("is-collapsed", IsCollapsed)
243+
.AddClass("is-fixed-tab", IsFixedTabHeader && UseTabSet)
239244
.AddClassFromAttributes(AdditionalAttributes)
240245
.Build();
241246

242247
private string? StyleString => CssBuilder.Default()
243248
.AddClass("--bb-layout-header-height: 0px;", Header == null)
244249
.AddClass("--bb-layout-footer-height: 0px;", ShowFooter == false || Footer == null)
250+
.AddClass("--bb-layout-height: 100vh;", IsPage && UseTabSet && IsFixedTabHeader)
245251
.AddStyleFromAttributes(AdditionalAttributes)
246252
.Build();
247253

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

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
--bb-layout-menu-user-border-color: #{$bb-layout-menu-user-border-color};
4040
--bb-layout-menu-item-hover-bg: #{$bb-layout-menu-item-hover-bg};
4141
display: flex;
42-
height: 100%;
42+
height: var(--bb-layout-height, 100%);
4343
width: 100%;
4444
flex-direction: column;
4545
position: relative;
@@ -114,17 +114,20 @@
114114
bottom: 0;
115115
left: 0;
116116
right: 0;
117-
z-index: 1036;
117+
z-index: 5;
118118
}
119119

120120
.layout-main {
121121
padding: 1rem;
122122
position: relative;
123-
min-height: calc(100vh - var(--bb-layout-header-height) - var(--bb-layout-footer-height));
124123
flex: 1;
125124

126125
.tabs.tabs-border-card {
127126
box-shadow: none;
127+
margin: -1rem;
128+
border: none;
129+
border-radius: unset;
130+
min-height: calc(100% + 2rem);
128131
}
129132
}
130133

@@ -136,7 +139,7 @@
136139
align-items: center;
137140
padding: 0 1rem;
138141
position: sticky;
139-
z-index: 1035;
142+
z-index: 1090;
140143
border-bottom: 1px solid var(--bb-layout-header-border-color);
141144

142145
&.is-fixed {
@@ -202,10 +205,6 @@
202205
}
203206

204207
.has-sidebar {
205-
.layout-side {
206-
z-index: 1030;
207-
}
208-
209208
.layout-main {
210209
overflow: hidden;
211210
height: calc(100vh - var(--bb-layout-header-height));
@@ -223,11 +222,31 @@
223222
border-top: 1px solid var(--bs-border-color);
224223

225224
&.is-fixed {
226-
z-index: 1035;
225+
z-index: 1090;
227226
position: sticky;
228227
bottom: 0;
229228
}
230229
}
230+
231+
&.is-fixed-tab {
232+
.layout-main {
233+
height: calc(100% - var(--bb-layout-header-height) - var(--bb-layout-footer-height));
234+
}
235+
236+
.tabs-body {
237+
height: calc(100% - var(--bb-tabs-item-height));
238+
overflow: auto;
239+
240+
.tabs-body-content {
241+
height: auto;
242+
min-height: 100%;
243+
}
244+
}
245+
246+
&:not(.has-footer) {
247+
--bb-layout-footer-height: 0;
248+
}
249+
}
231250
}
232251

233252
.has-sidebar {

0 commit comments

Comments
 (0)