From 5755024ee7a34a92e0c2cff4c38805ac52376c44 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 1 Feb 2025 11:39:57 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20Size=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/FileIcon/FileIcon.razor.cs | 9 ++++-- .../Components/FileIcon/FileIcon.razor.scss | 30 +++++++++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/BootstrapBlazor/Components/FileIcon/FileIcon.razor.cs b/src/BootstrapBlazor/Components/FileIcon/FileIcon.razor.cs index ee8f3493b93..60528d51f8d 100644 --- a/src/BootstrapBlazor/Components/FileIcon/FileIcon.razor.cs +++ b/src/BootstrapBlazor/Components/FileIcon/FileIcon.razor.cs @@ -11,6 +11,7 @@ namespace BootstrapBlazor.Components; public partial class FileIcon { private string? ClassString => CssBuilder.Default("file-icon") + .AddClass($"file-icon-{Size.ToDescriptionString()}", Size != Size.None) .AddClassFromAttributes(AdditionalAttributes) .Build(); @@ -22,9 +23,7 @@ public partial class FileIcon /// 获得/设置 文件类型扩展名 /// [Parameter] -#if NET6_0_OR_GREATER [EditorRequired] -#endif public string? Extension { get; set; } /// @@ -38,4 +37,10 @@ public partial class FileIcon /// [Parameter] public Color IconColor { get; set; } = Color.Primary; + + /// + /// 获得/设置 图标大小 默认 Color.None + /// + [Parameter] + public Size Size { get; set; } } diff --git a/src/BootstrapBlazor/Components/FileIcon/FileIcon.razor.scss b/src/BootstrapBlazor/Components/FileIcon/FileIcon.razor.scss index 0f33a7c9829..bf1c3d065fa 100644 --- a/src/BootstrapBlazor/Components/FileIcon/FileIcon.razor.scss +++ b/src/BootstrapBlazor/Components/FileIcon/FileIcon.razor.scss @@ -4,13 +4,14 @@ --bb-file-icon-padding-left: #{$bb-file-icon-padding-left}; --bb-file-icon-badge-bottom: #{$bb-file-icon-badge-bottom}; --bb-file-icon-path-fill-color: #{$bb-file-icon-path-fill-color}; + --bb-file-icon-size: 1; padding-left: var(--bb-file-icon-padding-left); display: inline-block; position: relative; .icon-svg { - width: var(--bb-file-icon-width); - height: var(--bb-file-icon-height); + width: calc(var(--bb-file-icon-width) * var(--bb-file-icon-size)); + height: calc(var(--bb-file-icon-height) * var(--bb-file-icon-size)); path { fill: var(--bb-file-icon-path-fill-color); @@ -21,5 +22,30 @@ position: absolute; bottom: var(--bb-file-icon-badge-bottom); left: 0; + font-size: calc(var(--bs-badge-font-size) * var(--bb-file-icon-size)); + } + + &.file-icon-xs { + --bb-file-icon-size: 0.5; + } + + &.file-icon-sm { + --bb-file-icon-size: 0.75; + } + + &.file-icon-md { + --bb-file-icon-size: 1.25; + } + + &.file-icon-lg { + --bb-file-icon-size: 1.5; + } + + &.file-icon-xl { + --bb-file-icon-size: 1.75; + } + + &.file-icon-xxl { + --bb-file-icon-size: 2; } } From 4453c60bc45c9d93c92e233522e4f692d2367760 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 1 Feb 2025 11:40:04 +0800 Subject: [PATCH 2/4] =?UTF-8?q?doc:=20=E5=A2=9E=E5=8A=A0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Samples/FileIcons.razor | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/BootstrapBlazor.Server/Components/Samples/FileIcons.razor b/src/BootstrapBlazor.Server/Components/Samples/FileIcons.razor index ad27338416e..731970f9aca 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/FileIcons.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/FileIcons.razor @@ -118,4 +118,37 @@ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ From 0ce46c2faf9707ceb0a763b04d457214dfd1fe36 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 1 Feb 2025 11:46:54 +0800 Subject: [PATCH 3/4] =?UTF-8?q?doc:=20=E5=A2=9E=E5=8A=A0=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=8C=96=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Server/Locales/en-US.json | 4 +++- src/BootstrapBlazor.Server/Locales/zh-CN.json | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor.Server/Locales/en-US.json b/src/BootstrapBlazor.Server/Locales/en-US.json index 606ae70c63f..d115d58e7b5 100644 --- a/src/BootstrapBlazor.Server/Locales/en-US.json +++ b/src/BootstrapBlazor.Server/Locales/en-US.json @@ -5961,7 +5961,9 @@ "CustomCssIntro": "Set class parameter set the style for the file icon component", "ExtensionAttr": "The extension of file", "IconColorAttr": "The backgound color for badge of extension", - "BackgroundTemplateAttr": "The template for custom the backgroup file" + "BackgroundTemplateAttr": "The template for custom the backgroup file", + "SizeTitle": "Size", + "SizeIntro":"Set the icon size by setting Size" }, "BootstrapBlazor.Server.Components.Samples.PdfReaders": { "Title": "PDF Reader", diff --git a/src/BootstrapBlazor.Server/Locales/zh-CN.json b/src/BootstrapBlazor.Server/Locales/zh-CN.json index 597e60ff85f..5a2c4257a3e 100644 --- a/src/BootstrapBlazor.Server/Locales/zh-CN.json +++ b/src/BootstrapBlazor.Server/Locales/zh-CN.json @@ -5961,7 +5961,9 @@ "CustomCssIntro": "通过设置 class 自定义样式调整图标大小", "ExtensionAttr": "文件扩展名", "IconColorAttr": "扩展名标签背景色", - "BackgroundTemplateAttr": "自定义背景图模板" + "BackgroundTemplateAttr": "自定义背景图模板", + "SizeTitle": "大小", + "SizeIntro": "通过设置 Size 设置图标大小" }, "BootstrapBlazor.Server.Components.Samples.PdfReaders": { "Title": "PDF Reader PDF阅读器", From d3a54b9cb742364b1895e49a7fa6965bce8a7ea1 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 1 Feb 2025 11:50:14 +0800 Subject: [PATCH 4/4] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/FileIconTest.cs | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/UnitTest/Components/FileIconTest.cs b/test/UnitTest/Components/FileIconTest.cs index 4004124a9c7..fd6ec17c9cf 100644 --- a/test/UnitTest/Components/FileIconTest.cs +++ b/test/UnitTest/Components/FileIconTest.cs @@ -39,4 +39,33 @@ public void BackgroundTemplate_Ok() }); cut.Contains("test-content"); } + + [Theory] + [InlineData(Size.ExtraSmall)] + [InlineData(Size.Small)] + [InlineData(Size.Medium)] + [InlineData(Size.Large)] + [InlineData(Size.ExtraLarge)] + [InlineData(Size.ExtraExtraLarge)] + public void Size_Ok(Size size) + { + var cut = Context.RenderComponent(pb => + { + pb.Add(a => a.Extension, ".xlsx"); + pb.Add(a => a.Size, size); + }); + cut.Contains($"file-icon file-icon-{size.ToDescriptionString()}"); + } + + [Fact] + public void Size_None() + { + var cut = Context.RenderComponent(pb => + { + pb.Add(a => a.Extension, ".xlsx"); + pb.Add(a => a.Size, Size.None); + }); + cut.Contains("file-icon"); + cut.DoesNotContain("file-icon-none"); + } }