Skip to content

Commit 5755024

Browse files
committed
feat: 增加 Size 参数
1 parent e1f1352 commit 5755024

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

src/BootstrapBlazor/Components/FileIcon/FileIcon.razor.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace BootstrapBlazor.Components;
1111
public partial class FileIcon
1212
{
1313
private string? ClassString => CssBuilder.Default("file-icon")
14+
.AddClass($"file-icon-{Size.ToDescriptionString()}", Size != Size.None)
1415
.AddClassFromAttributes(AdditionalAttributes)
1516
.Build();
1617

@@ -22,9 +23,7 @@ public partial class FileIcon
2223
/// 获得/设置 文件类型扩展名
2324
/// </summary>
2425
[Parameter]
25-
#if NET6_0_OR_GREATER
2626
[EditorRequired]
27-
#endif
2827
public string? Extension { get; set; }
2928

3029
/// <summary>
@@ -38,4 +37,10 @@ public partial class FileIcon
3837
/// </summary>
3938
[Parameter]
4039
public Color IconColor { get; set; } = Color.Primary;
40+
41+
/// <summary>
42+
/// 获得/设置 图标大小 默认 Color.None
43+
/// </summary>
44+
[Parameter]
45+
public Size Size { get; set; }
4146
}

src/BootstrapBlazor/Components/FileIcon/FileIcon.razor.scss

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
--bb-file-icon-padding-left: #{$bb-file-icon-padding-left};
55
--bb-file-icon-badge-bottom: #{$bb-file-icon-badge-bottom};
66
--bb-file-icon-path-fill-color: #{$bb-file-icon-path-fill-color};
7+
--bb-file-icon-size: 1;
78
padding-left: var(--bb-file-icon-padding-left);
89
display: inline-block;
910
position: relative;
1011

1112
.icon-svg {
12-
width: var(--bb-file-icon-width);
13-
height: var(--bb-file-icon-height);
13+
width: calc(var(--bb-file-icon-width) * var(--bb-file-icon-size));
14+
height: calc(var(--bb-file-icon-height) * var(--bb-file-icon-size));
1415

1516
path {
1617
fill: var(--bb-file-icon-path-fill-color);
@@ -21,5 +22,30 @@
2122
position: absolute;
2223
bottom: var(--bb-file-icon-badge-bottom);
2324
left: 0;
25+
font-size: calc(var(--bs-badge-font-size) * var(--bb-file-icon-size));
26+
}
27+
28+
&.file-icon-xs {
29+
--bb-file-icon-size: 0.5;
30+
}
31+
32+
&.file-icon-sm {
33+
--bb-file-icon-size: 0.75;
34+
}
35+
36+
&.file-icon-md {
37+
--bb-file-icon-size: 1.25;
38+
}
39+
40+
&.file-icon-lg {
41+
--bb-file-icon-size: 1.5;
42+
}
43+
44+
&.file-icon-xl {
45+
--bb-file-icon-size: 1.75;
46+
}
47+
48+
&.file-icon-xxl {
49+
--bb-file-icon-size: 2;
2450
}
2551
}

0 commit comments

Comments
 (0)