Skip to content

Commit 2a050a1

Browse files
authored
feat(Drawer): add ZIndex parameter (#5396)
* chore: bump version 9.3.1-beta22 * test: 增加单元测试 * feat: 增加 ZIndex 参数 * refactor: 增加 ZIndex 参数传递逻辑 * feat: 增加 ZIndex 样式 * test: 增加单元测试
1 parent 49adb87 commit 2a050a1

File tree

6 files changed

+31
-3
lines changed

6 files changed

+31
-3
lines changed

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

77
<ItemGroup>

src/BootstrapBlazor/Components/Drawer/Drawer.razor.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public partial class Drawer
2020

2121
private string? StyleString => CssBuilder.Default()
2222
.AddStyle("--bb-drawer-position", Position)
23+
.AddClass($"--bb-drawer-zindex: {ZIndex};", ZIndex.HasValue)
2324
.AddStyleFromAttributes(AdditionalAttributes)
2425
.Build();
2526

@@ -107,6 +108,12 @@ public partial class Drawer
107108
[Parameter]
108109
public bool AllowResize { get; set; }
109110

111+
/// <summary>
112+
/// 获得/设置 z-index 参数值 默认 null 未设置
113+
/// </summary>
114+
[Parameter]
115+
public int? ZIndex { get; set; }
116+
110117
/// <summary>
111118
/// 获得/设置 关闭抽屉回调委托 默认 null
112119
/// </summary>
@@ -133,7 +140,7 @@ public partial class Drawer
133140

134141
private string? KeyboardString => IsKeyboard ? "true" : null;
135142

136-
private string? BodyScrollString => BodyScroll ? "true" : null;
143+
private string? BodyScrollString => BodyScroll ? "true" : null;
137144

138145
/// <summary>
139146
/// <inheritdoc/>

src/BootstrapBlazor/Components/Drawer/DrawerContainer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ private Dictionary<string, object> GetParameters(DrawerOption option)
8181
{
8282
parameters.Add(nameof(Drawer.Height), option.Height);
8383
}
84+
if (option.ZIndex.HasValue)
85+
{
86+
parameters.Add(nameof(Drawer.ZIndex), option.ZIndex);
87+
}
8488
var content = option.GetContent();
8589
if (content != null)
8690
{

src/BootstrapBlazor/Components/Drawer/DrawerOption.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,9 @@ public class DrawerOption
7979
/// 获得/设置 相关连数据,多用于传值使用
8080
/// </summary>
8181
public object? BodyContext { get; set; }
82+
83+
/// <summary>
84+
/// 获得/设置 z-index 参数值 默认 null 未设置
85+
/// </summary>
86+
public int? ZIndex { get; set; }
8287
}

test/UnitTest/Components/DrawerTest.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ public void Position_Ok()
161161
cut.Contains("--bb-drawer-position: absolute;");
162162
}
163163

164+
[Fact]
165+
public void ZIndex_Ok()
166+
{
167+
var cut = Context.RenderComponent<Drawer>(builder =>
168+
{
169+
builder.Add(a => a.ZIndex, 1055);
170+
});
171+
cut.Contains("--bb-drawer-zindex: 1055;");
172+
}
173+
164174
[Fact]
165175
public void IsKeyboard_Ok()
166176
{

test/UnitTest/Services/DrawerServiceTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ public async Task Show_Ok()
2525
ShowBackdrop = true,
2626
BodyContext = "test-body-context",
2727
IsKeyboard = true,
28-
BodyScroll = true
28+
BodyScroll = true,
29+
ZIndex = 1066
2930
};
3031
var service = Context.Services.GetRequiredService<DrawerService>();
3132
var cut = Context.RenderComponent<BootstrapBlazorRoot>();
3233
await service.Show(option);
3334
cut.Contains("data-bb-keyboard=\"true\"");
35+
cut.Contains("--bb-drawer-zindex: 1066;");
3436
var button = cut.Find("button");
3537
await cut.InvokeAsync(() => button.Click());
3638

0 commit comments

Comments
 (0)