Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.4.9-beta05</Version>
<Version>9.4.9-beta06</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public partial class Dialog : IDisposable
private Dictionary<string, object>? _currentParameter;
private bool _isKeyboard = false;
private bool _isBackdrop = false;
private bool _isFade = true;
private bool? _isFade = null;

/// <summary>
/// <inheritdoc/>
Expand Down
4 changes: 2 additions & 2 deletions src/BootstrapBlazor/Components/Dialog/DialogOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public class DialogOption
public bool ShowHeaderCloseButton { get; set; } = true;

/// <summary>
/// Gets or sets whether to enable fade animation, default is true
/// Gets or sets whether to enable fade animation, default is null
/// </summary>
public bool IsFade { get; set; } = true;
public bool? IsFade { get; set; }

/// <summary>
/// Gets or sets whether to support closing the dialog with the ESC key, default is true
Expand Down
10 changes: 7 additions & 3 deletions src/BootstrapBlazor/Components/Modal/Modal.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ namespace BootstrapBlazor.Components;
/// </summary>
public partial class Modal
{
[Inject]
[NotNull]
private IOptionsMonitor<BootstrapBlazorOptions>? Options { get; set; }

/// <summary>
/// Gets the style string
/// </summary>
private string? ClassString => CssBuilder.Default("modal")
.AddClass("fade", IsFade)
.AddClass("fade", Options.CurrentValue.GetIsFadeValue(IsFade))
.AddClassFromAttributes(AdditionalAttributes)
.Build();

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

/// <summary>
/// Gets or sets whether to enable fade in and out animation, default is true to enable animation
/// Gets or sets whether to enable fade in and out animation, default is null
/// </summary>
[Parameter]
public bool IsFade { get; set; } = true;
public bool? IsFade { get; set; }

/// <summary>
/// Gets or sets the child component
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/SweetAlert/SweetAlert.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@inherits BootstrapComponentBase
@inject SwalService Swal

<Modal @ref="ModalContainer" IsKeyboard="false" OnCloseAsync="OnCloseAsync" class="swal">
<Modal @ref="ModalContainer" IsKeyboard="false" OnCloseAsync="OnCloseAsync" IsFade="true" class="swal">
@RenderDialog()
</Modal>
26 changes: 17 additions & 9 deletions src/BootstrapBlazor/Extensions/BootstrapBlazorOptionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,35 @@
namespace BootstrapBlazor.Components;

/// <summary>
/// BootstrapBlazorOptions 配置类扩展方法
/// BootstrapBlazorOptions configuration class extension methods
/// </summary>
public static class BootstrapBlazorOptionsExtensions
{
/// <summary>
/// 获取步长泛型方法
/// Get step size generic method
/// </summary>
/// <typeparam name="TType"></typeparam>
/// <param name="options"></param>
/// <returns></returns>
/// <typeparam name="TType">The type parameter</typeparam>
/// <param name="options">The BootstrapBlazorOptions instance</param>
/// <returns>The step size as a string</returns>
public static string? GetStep<TType>(this BootstrapBlazorOptions options) => options.GetStep(typeof(TType));

/// <summary>
/// 获取步长方法
/// Get step size method
/// </summary>
/// <param name="options">配置实体类实例</param>
/// <param name="type">数据类型</param>
/// <returns></returns>
/// <param name="options">The BootstrapBlazorOptions instance</param>
/// <param name="type">The data type</param>
/// <returns>The step size as a string</returns>
public static string? GetStep(this BootstrapBlazorOptions options, Type type)
{
var t = Nullable.GetUnderlyingType(type) ?? type;
return options.StepSettings.GetStep(t);
}

/// <summary>
/// Get Modal IsFade value
/// </summary>
/// <param name="options">The BootstrapBlazorOptions instance</param>
/// <param name="value">The default value</param>
/// <returns>The IsFade value as a boolean</returns>
public static bool GetIsFadeValue(this BootstrapBlazorOptions options, bool? value) => value ?? options.ModalSettings.IsFade ?? true;
}
19 changes: 12 additions & 7 deletions src/BootstrapBlazor/Options/BootstrapBlazorOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,42 +86,47 @@ public class BootstrapBlazorOptions : IOptions<BootstrapBlazorOptions>
public string? JSModuleVersion { get; set; }

/// <summary>
/// Gets or sets the table settings instance
/// Gets or sets the <see cref="TableSettings"/> configuration instance
/// </summary>
public TableSettings TableSettings { get; set; } = new();

/// <summary>
/// Gets or sets the <see cref="ModalSettings"/> configuration instance
/// </summary>
public ModalSettings ModalSettings { get; set; } = new();

/// <summary>
/// Gets or sets the <see cref="StepSettings"/> configuration instance
/// </summary>
public StepSettings StepSettings { get; set; } = new();

/// <summary>
/// Gets or sets the <see cref="ConnectionHubOptions"/> configuration, default is not null
/// Gets or sets the <see cref="ConnectionHubOptions"/> configuration
/// </summary>
public ConnectionHubOptions ConnectionHubOptions { get; set; } = new();

/// <summary>
/// Gets or sets the <see cref="WebClientOptions"/> configuration, default is not null
/// Gets or sets the <see cref="WebClientOptions"/> configuration
/// </summary>
public WebClientOptions WebClientOptions { get; set; } = new();

/// <summary>
/// Gets or sets the <see cref="IpLocatorOptions"/> configuration, default is not null
/// Gets or sets the <see cref="IpLocatorOptions"/> configuration
/// </summary>
public IpLocatorOptions IpLocatorOptions { get; set; } = new();

/// <summary>
/// Gets or sets the <see cref="ScrollOptions"/> configuration, default is not null
/// Gets or sets the <see cref="ScrollOptions"/> configuration
/// </summary>
public ScrollOptions ScrollOptions { get; set; } = new();

/// <summary>
/// Gets or sets the <see cref="ContextMenuOptions"/> configuration, default is not null
/// Gets or sets the <see cref="ContextMenuOptions"/> configuration
/// </summary>
public ContextMenuOptions ContextMenuOptions { get; set; } = new();

/// <summary>
/// Gets or sets the CacheManagerOptions configuration, default is not null
/// Gets or sets the CacheManagerOptions configuration
/// </summary>
public CacheManagerOptions CacheManagerOptions { get; set; } = new();

Expand Down
17 changes: 17 additions & 0 deletions src/BootstrapBlazor/Options/ModalSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone

namespace BootstrapBlazor.Components;

/// <summary>
/// Modal component settings
/// </summary>
public class ModalSettings
{
/// <summary>
/// Gets or sets whether to enable fade animation, default is null
/// </summary>
public bool? IsFade { get; set; }
}