From 322a293c67be3e84fbff053b31c07b94d9b5b4d7 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Thu, 30 Jun 2022 18:48:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?wip:=20=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Progress/Progress.razor | 2 +- src/BootstrapBlazor/Components/Progress/ProgressBase.cs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Progress/Progress.razor b/src/BootstrapBlazor/Components/Progress/Progress.razor index 1207100d6..74751adc1 100644 --- a/src/BootstrapBlazor/Components/Progress/Progress.razor +++ b/src/BootstrapBlazor/Components/Progress/Progress.razor @@ -1,6 +1,6 @@ @namespace BootstrapBlazor.Components @inherits ProgressBase -
+
@ValueLabelString
diff --git a/src/BootstrapBlazor/Components/Progress/ProgressBase.cs b/src/BootstrapBlazor/Components/Progress/ProgressBase.cs index 171ae5783..7f2bf8735 100644 --- a/src/BootstrapBlazor/Components/Progress/ProgressBase.cs +++ b/src/BootstrapBlazor/Components/Progress/ProgressBase.cs @@ -9,6 +9,12 @@ namespace BootstrapBlazor.Components; /// public abstract class ProgressBase : BootstrapComponentBase { + /// + /// + /// + protected string? ClassString => CssBuilder.Default("progress") + .Build(); + /// /// 获得 样式集合 /// -- Gitee From 69546df3c876aacc00be202dd946a14168fbf3f1 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Fri, 1 Jul 2022 10:30:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20Progress.razor?= =?UTF-8?q?.cs=20=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Progress/Progress.razor.cs | 59 +++++++++++++++++++ .../Components/Progress/ProgressBase.cs | 54 +---------------- 2 files changed, 60 insertions(+), 53 deletions(-) create mode 100644 src/BootstrapBlazor/Components/Progress/Progress.razor.cs diff --git a/src/BootstrapBlazor/Components/Progress/Progress.razor.cs b/src/BootstrapBlazor/Components/Progress/Progress.razor.cs new file mode 100644 index 000000000..c6b4c3c6f --- /dev/null +++ b/src/BootstrapBlazor/Components/Progress/Progress.razor.cs @@ -0,0 +1,59 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Website: https://www.blazor.zone or https://argozhang.github.io/ + +namespace BootstrapBlazor.Components; + +/// +/// Progress 组件 +/// +public partial class Progress +{ + private string? ClassString => CssBuilder.Default("progress") + .AddClassFromAttributes(AdditionalAttributes) + .Build(); + + /// + /// 获得 样式集合 + /// + /// + private string? ClassName => CssBuilder.Default("progress-bar") + .AddClass($"bg-{Color.ToDescriptionString()}", Color != Color.None) + .AddClass("progress-bar-striped", IsStriped) + .AddClass("progress-bar-animated", IsAnimated) + .Build(); + + /// + /// 获得 Style 集合 + /// + private string? StyleName => CssBuilder.Default() + .AddClass($"width: {Value}%;") + .Build(); + + /// + /// 获得 ProgressStyle 集合 + /// + private string? ProgressStyle => CssBuilder.Default() + .AddClass($"height: {Height}px;", Height.HasValue) + .Build(); + + /// + /// 获得 当前值 + /// + private string ValueString => Value.ToString(); + + /// + /// 获得 当前值百分比标签文字 + /// + private string? ValueLabelString => IsShowValue ? $"{Value}%" : null; + + /// + /// OnParametersSet 方法 + /// + protected override void OnParametersSet() + { + base.OnParametersSet(); + + Value = Math.Min(100, Math.Max(0, Value)); + } +} diff --git a/src/BootstrapBlazor/Components/Progress/ProgressBase.cs b/src/BootstrapBlazor/Components/Progress/ProgressBase.cs index 7f2bf8735..bc5f296f3 100644 --- a/src/BootstrapBlazor/Components/Progress/ProgressBase.cs +++ b/src/BootstrapBlazor/Components/Progress/ProgressBase.cs @@ -9,37 +9,6 @@ namespace BootstrapBlazor.Components; /// public abstract class ProgressBase : BootstrapComponentBase { - /// - /// - /// - protected string? ClassString => CssBuilder.Default("progress") - .Build(); - - /// - /// 获得 样式集合 - /// - /// - protected string? ClassName => CssBuilder.Default("progress-bar") - .AddClass($"bg-{Color.ToDescriptionString()}", Color != Color.None) - .AddClass("progress-bar-striped", IsStriped) - .AddClass("progress-bar-animated", IsAnimated) - .AddClassFromAttributes(AdditionalAttributes) - .Build(); - - /// - /// 获得 Style 集合 - /// - protected string? StyleName => CssBuilder.Default() - .AddClass($"width: {Value}%;") - .Build(); - - /// - /// 获得 ProgressStyle 集合 - /// - protected string? ProgressStyle => CssBuilder.Default() - .AddClass($"height: {Height}px;", Height.HasValue) - .Build(); - /// /// 获得/设置 控件高度默认 20px /// @@ -68,30 +37,9 @@ public abstract class ProgressBase : BootstrapComponentBase /// [Parameter] public bool IsAnimated { get; set; } - private int _value; /// /// 获得/设置 组件进度值 /// [Parameter] - public int Value - { - set - { - _value = value; - } - get - { - return Math.Min(100, Math.Max(0, _value)); - } - } - - /// - /// 获得 当前值 - /// - protected string ValueString => Value.ToString(); - - /// - /// 获得 当前值百分比标签文字 - /// - protected string? ValueLabelString => IsShowValue ? $"{Value}%" : null; + public int Value { get; set; } } -- Gitee