Skip to content

Commit 4a2f5bb

Browse files
authored
feat(Layout): add SidebarMinWidth/SidebarMaxWidth parameter (#5452)
* refactor: 更改参数名称 * doc: 代码格式化 * feat: 增加 SidebarMin/MaxValue 参数 * test: 更新单元测试 * doc: 更新文档 * chore: bump version 9.3.1-beta37 * refactor: 更改参数名称 * chore: bump version 9.3.1-beta38
1 parent 32a4c0a commit 4a2f5bb

File tree

8 files changed

+54
-8
lines changed

8 files changed

+54
-8
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,30 @@ private AttributeItem[] GetAttributes() =>
124124
DefaultValue = "false"
125125
},
126126
new()
127+
{
128+
Name = "SidebarMinWidth",
129+
Description = Localizer["Layouts_SidebarMinWidth_Description"],
130+
Type = "int?",
131+
ValueList = " — ",
132+
DefaultValue = " — "
133+
},
134+
new()
135+
{
136+
Name = "SidebarMaxWidth",
137+
Description = Localizer["Layouts_SidebarMaxWidth_Description"],
138+
Type = "int?",
139+
ValueList = " — ",
140+
DefaultValue = " — "
141+
},
142+
new()
143+
{
144+
Name = "ShowSplitebar",
145+
Description = Localizer["Layouts_ShowSplitebar_Description"],
146+
Type = "bool",
147+
ValueList = "true|false",
148+
DefaultValue = "false"
149+
},
150+
new()
127151
{
128152
Name = "ShowFooter",
129153
Description = Localizer["Layouts_ShowFooter_Description"],

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,9 @@
14321432
"Layouts_IsFixedFooter_Description": "Whether to fix the Footer component",
14331433
"Layouts_IsFixedHeader_Description": "Whether to fix the Header component",
14341434
"Layouts_ShowCollapseBar_Description": "Whether to show contraction and expansion Bar",
1435+
"Layouts_ShowSplitebar_Description": "Whether to display the left and right split bar",
1436+
"Layouts_SidebarMinWidth_Description": "Minimum sidebar width",
1437+
"Layouts_SidebarMaxWidth_Description": "Maximum sidebar width",
14351438
"Layouts_ShowFooter_Description": "Whether to show Footer template",
14361439
"Layouts_ShowGotoTop_Description": "Whether to display the back to top button",
14371440
"Layouts_UseTabSet_Description": "Whether to open multi-label mode",

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,9 @@
14321432
"Layouts_IsFixedFooter_Description": "是否固定 Footer 组件",
14331433
"Layouts_IsFixedHeader_Description": "是否固定 Header 组件",
14341434
"Layouts_ShowCollapseBar_Description": "是否显示收缩展开 Bar",
1435+
"Layouts_ShowSplitebar_Description": "是否显示左右分割栏",
1436+
"Layouts_SidebarMinWidth_Description": "侧边栏最小宽度",
1437+
"Layouts_SidebarMaxWidth_Description": "侧边栏最大宽度",
14351438
"Layouts_ShowFooter_Description": "是否显示 Footer 模板",
14361439
"Layouts_ShowGotoTop_Description": "是否显示返回顶端按钮",
14371440
"Layouts_UseTabSet_Description": "是否开启多标签模式",

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-beta36</Version>
4+
<Version>9.3.1-beta38</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Layout/Layout.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@
8888
{
8989
@Side
9090
}
91-
@if (ShowSplitBar)
91+
@if (ShowSplitebar)
9292
{
93-
<LayoutSplitebar></LayoutSplitebar>
93+
<LayoutSplitebar Min="SidebarMinWidth" Max="SidebarMaxWidth"></LayoutSplitebar>
9494
}
9595
@if (Menus != null)
9696
{

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,19 @@ public partial class Layout : IHandlerException
7070
/// 仅在 左右布局时有效
7171
/// </summary>
7272
[Parameter]
73-
public bool ShowSplitBar { get; set; }
73+
public bool ShowSplitebar { get; set; }
74+
75+
/// <summary>
76+
/// 获得/设置 侧边栏最小宽度 默认 null 未设置
77+
/// </summary>
78+
[Parameter]
79+
public int? SidebarMinWidth { get; set; }
80+
81+
/// <summary>
82+
/// 获得/设置 侧边栏最大宽度 默认 null 未设置
83+
/// </summary>
84+
[Parameter]
85+
public int? SidebarMaxWidth { get; set; }
7486

7587
/// <summary>
7688
/// 获得/设置 NotAuthorized 模板 默认 null NET6.0/7.0 有效

src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
{
77
<CascadingValue Value="this" IsFixed="true">
88
<EditForm @attributes="@AdditionalAttributes" id="@Id" Model="@Model"
9-
data-bb-dissubmit="@DisableAutoSubmitString" data-bb-invalid-result="@ShowAllInvalidResultString"
10-
style="@StyleString"
11-
OnValidSubmit="@OnValidSubmitForm" OnInvalidSubmit="@OnInvalidSubmitForm">
9+
data-bb-dissubmit="@DisableAutoSubmitString" data-bb-invalid-result="@ShowAllInvalidResultString"
10+
style="@StyleString"
11+
OnValidSubmit="@OnValidSubmitForm" OnInvalidSubmit="@OnInvalidSubmitForm">
1212
<BootstrapBlazorDataAnnotationsValidator @ref="Validator" />
1313
@ChildContent
1414
</EditForm>

test/UnitTest/Components/LayoutTest.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,17 @@ public void ShowLayouSidebar_Ok()
245245
pb.Add(a => a.UseTabSet, true);
246246
pb.Add(a => a.AdditionalAssemblies, new Assembly[] { GetType().Assembly });
247247
pb.Add(a => a.IsFullSide, true);
248-
pb.Add(a => a.ShowSplitBar, true);
248+
pb.Add(a => a.ShowSplitebar, true);
249+
pb.Add(a => a.SidebarMinWidth, 100);
250+
pb.Add(a => a.SidebarMaxWidth, 300);
249251
pb.Add(a => a.Side, new RenderFragment(builder =>
250252
{
251253
builder.AddContent(0, "test");
252254
}));
253255
});
254256
cut.Contains("layout-splitebar");
257+
cut.Contains("data-bb-min=\"100\"");
258+
cut.Contains("data-bb-max=\"300\"");
255259
}
256260

257261
[Fact]

0 commit comments

Comments
 (0)