Skip to content

Commit 99bf6ce

Browse files
committed
feat: 增加 IsFade 取值逻辑
1 parent 5a9eb85 commit 99bf6ce

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public partial class Dialog : IDisposable
2727
private Dictionary<string, object>? _currentParameter;
2828
private bool _isKeyboard = false;
2929
private bool _isBackdrop = false;
30-
private bool _isFade = true;
30+
private bool? _isFade = null;
3131

3232
/// <summary>
3333
/// <inheritdoc/>

src/BootstrapBlazor/Components/Dialog/DialogOption.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public class DialogOption
6868
public bool ShowHeaderCloseButton { get; set; } = true;
6969

7070
/// <summary>
71-
/// Gets or sets whether to enable fade animation, default is true
71+
/// Gets or sets whether to enable fade animation, default is null
7272
/// </summary>
73-
public bool IsFade { get; set; } = true;
73+
public bool? IsFade { get; set; }
7474

7575
/// <summary>
7676
/// Gets or sets whether to support closing the dialog with the ESC key, default is true

src/BootstrapBlazor/Components/Modal/Modal.razor.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ namespace BootstrapBlazor.Components;
1212
/// </summary>
1313
public partial class Modal
1414
{
15+
[Inject]
16+
[NotNull]
17+
private IOptionsMonitor<BootstrapBlazorOptions>? Options { get; set; }
18+
1519
/// <summary>
1620
/// Gets the style string
1721
/// </summary>
1822
private string? ClassString => CssBuilder.Default("modal")
19-
.AddClass("fade", IsFade)
23+
.AddClass("fade", Options.CurrentValue.GetIsFadeValue(IsFade))
2024
.AddClassFromAttributes(AdditionalAttributes)
2125
.Build();
2226

@@ -40,10 +44,10 @@ public partial class Modal
4044
public bool IsKeyboard { get; set; } = true;
4145

4246
/// <summary>
43-
/// Gets or sets whether to enable fade in and out animation, default is true to enable animation
47+
/// Gets or sets whether to enable fade in and out animation, default is null
4448
/// </summary>
4549
[Parameter]
46-
public bool IsFade { get; set; } = true;
50+
public bool? IsFade { get; set; }
4751

4852
/// <summary>
4953
/// Gets or sets the child component

src/BootstrapBlazor/Extensions/BootstrapBlazorOptionsExtensions.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,35 @@
66
namespace BootstrapBlazor.Components;
77

88
/// <summary>
9-
/// BootstrapBlazorOptions 配置类扩展方法
9+
/// BootstrapBlazorOptions configuration class extension methods
1010
/// </summary>
1111
public static class BootstrapBlazorOptionsExtensions
1212
{
1313
/// <summary>
14-
/// 获取步长泛型方法
14+
/// Get step size generic method
1515
/// </summary>
16-
/// <typeparam name="TType"></typeparam>
17-
/// <param name="options"></param>
18-
/// <returns></returns>
16+
/// <typeparam name="TType">The type parameter</typeparam>
17+
/// <param name="options">The BootstrapBlazorOptions instance</param>
18+
/// <returns>The step size as a string</returns>
1919
public static string? GetStep<TType>(this BootstrapBlazorOptions options) => options.GetStep(typeof(TType));
2020

2121
/// <summary>
22-
/// 获取步长方法
22+
/// Get step size method
2323
/// </summary>
24-
/// <param name="options">配置实体类实例</param>
25-
/// <param name="type">数据类型</param>
26-
/// <returns></returns>
24+
/// <param name="options">The BootstrapBlazorOptions instance</param>
25+
/// <param name="type">The data type</param>
26+
/// <returns>The step size as a string</returns>
2727
public static string? GetStep(this BootstrapBlazorOptions options, Type type)
2828
{
2929
var t = Nullable.GetUnderlyingType(type) ?? type;
3030
return options.StepSettings.GetStep(t);
3131
}
32+
33+
/// <summary>
34+
/// Get Modal IsFade value
35+
/// </summary>
36+
/// <param name="options">The BootstrapBlazorOptions instance</param>
37+
/// <param name="value">The default value</param>
38+
/// <returns>The IsFade value as a boolean</returns>
39+
public static bool GetIsFadeValue(this BootstrapBlazorOptions options, bool? value) => options.ModalSettings.IsFade ?? value ?? true;
3240
}

0 commit comments

Comments
 (0)