Skip to content

Commit 4a6cd16

Browse files
authored
feat(ImagePreview): support class/style html attirbute (#7032)
1 parent 54cb560 commit 4a6cd16

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/BootstrapBlazor/Components/ImagePreviewer/ImagePreviewer.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@inherits BootstrapModuleComponentBase
33
@attribute [BootstrapModuleAutoLoader]
44

5-
<div tabindex="-1" class="bb-previewer collapse active" id="@Id" style="z-index: @ZIndex;">
5+
<div attributes="@AdditionalAttributes" id="@Id" tabindex="-1" class="@ClassString" style="@StyleString">
66
<div class="bb-viewer-mask"></div>
77
<div class="bb-viewer-canvas">
88
<img src="@GetFirstImageUrl()" class="bb-viewer-img" style="transform: scale(1) rotate(0deg); margin: 0;" />

src/BootstrapBlazor/Components/ImagePreviewer/ImagePreviewer.razor.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ public partial class ImagePreviewer
9292

9393
private bool ShowButtons => PreviewList.Count > 1;
9494

95+
private string? ClassString => CssBuilder.Default("bb-previewer collapse active")
96+
.AddClassFromAttributes(AdditionalAttributes)
97+
.Build();
98+
99+
private string? StyleString => CssBuilder.Default()
100+
.AddClass($"--bb-viewer-zindex: {ZIndex};", ZIndex > 0)
101+
.AddStyleFromAttributes(AdditionalAttributes)
102+
.Build();
103+
95104
/// <summary>
96105
/// 显示图片
97106
/// </summary>

src/BootstrapBlazor/Components/ImagePreviewer/ImagePreviewer.razor.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
right: 0;
99
bottom: 0;
1010
left: 0;
11+
z-index: var(--bb-viewer-zindex, 5);
1112

1213
&.active {
1314
.bb-viewer-full-screen {

0 commit comments

Comments
 (0)