Skip to content

Commit

Permalink
Fix settings to allow instance settings to override global settings (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissainty authored Jun 30, 2023
1 parent 240acae commit 1f0f1d8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Blazored.Toast/BlazoredToast.razor
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ else

<p class="blazored-toast-message">@Message</p>

@if (Settings.DisableTimeout!.Value || Settings.ShowCloseButton)
@if (Settings.DisableTimeout!.Value || Settings.ShowCloseButton!.Value)
{
<button type="button" class="blazored-toast-close" @onclick=@Close>
<i aria-label="icon: close" class="blazored-toast-close-icon">
Expand Down
2 changes: 1 addition & 1 deletion src/Blazored.Toast/BlazoredToast.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected override async Task OnInitializedAsync()
return;
}

if (Settings.ShowProgressBar)
if (Settings.ShowProgressBar!.Value)
{
_countdownTimer = new CountdownTimer(Settings.Timeout, Settings.ExtendedTimeout!.Value)
.OnTick(CalculateProgressAsync)
Expand Down
18 changes: 9 additions & 9 deletions src/Blazored.Toast/BlazoredToasts.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public partial class BlazoredToasts
[Parameter] public RenderFragment? CloseButtonContent { get; set; }
[Parameter] public bool ShowCloseButton { get; set; } = true;
[Parameter] public bool DisableTimeout { get; set; }
[Parameter] public bool PauseProgressOnHover { get; set; } = false;
[Parameter] public bool PauseProgressOnHover { get; set; }
[Parameter] public int ExtendedTimeout { get; set; }

private List<ToastInstance> ToastList { get; set; } = new();
Expand Down Expand Up @@ -82,8 +82,8 @@ private ToastSettings BuildToastSettings(ToastLevel level, RenderFragment messag
$"blazored-toast-error {toastInstanceSettings.AdditionalClasses}",
toastInstanceSettings.IconType ?? IconType,
toastInstanceSettings.Icon ?? ErrorIcon ?? "",
ShowProgressBar,
ShowCloseButton,
toastInstanceSettings.ShowProgressBar ?? ShowProgressBar,
toastInstanceSettings.ShowCloseButton ?? ShowCloseButton,
toastInstanceSettings.OnClick,
toastInstanceSettings.Timeout == 0 ? Timeout : toastInstanceSettings.Timeout,
toastInstanceSettings.DisableTimeout ?? DisableTimeout,
Expand All @@ -94,8 +94,8 @@ private ToastSettings BuildToastSettings(ToastLevel level, RenderFragment messag
$"blazored-toast-info {toastInstanceSettings.AdditionalClasses}",
toastInstanceSettings.IconType ?? IconType,
toastInstanceSettings.Icon ?? InfoIcon ?? "",
ShowProgressBar,
ShowCloseButton,
toastInstanceSettings.ShowProgressBar ?? ShowProgressBar,
toastInstanceSettings.ShowCloseButton ?? ShowCloseButton,
toastInstanceSettings.OnClick,
toastInstanceSettings.Timeout == 0 ? Timeout : toastInstanceSettings.Timeout,
toastInstanceSettings.DisableTimeout ?? DisableTimeout,
Expand All @@ -106,8 +106,8 @@ private ToastSettings BuildToastSettings(ToastLevel level, RenderFragment messag
$"blazored-toast-success {toastInstanceSettings.AdditionalClasses}",
toastInstanceSettings.IconType ?? IconType,
toastInstanceSettings.Icon ?? SuccessIcon ?? "",
ShowProgressBar,
ShowCloseButton,
toastInstanceSettings.ShowProgressBar ?? ShowProgressBar,
toastInstanceSettings.ShowCloseButton ?? ShowCloseButton,
toastInstanceSettings.OnClick,
toastInstanceSettings.Timeout == 0 ? Timeout : toastInstanceSettings.Timeout,
toastInstanceSettings.DisableTimeout ?? DisableTimeout,
Expand All @@ -118,8 +118,8 @@ private ToastSettings BuildToastSettings(ToastLevel level, RenderFragment messag
$"blazored-toast-warning {toastInstanceSettings.AdditionalClasses}",
toastInstanceSettings.IconType ?? IconType,
toastInstanceSettings.Icon ?? WarningIcon ?? "",
ShowProgressBar,
ShowCloseButton,
toastInstanceSettings.ShowProgressBar ?? ShowProgressBar,
toastInstanceSettings.ShowCloseButton ?? ShowCloseButton,
toastInstanceSettings.OnClick,
toastInstanceSettings.Timeout == 0 ? Timeout : toastInstanceSettings.Timeout,
toastInstanceSettings.DisableTimeout ?? DisableTimeout,
Expand Down
4 changes: 2 additions & 2 deletions src/Blazored.Toast/Configuration/ToastSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ToastSettings
/// <summary>
/// Enabling the <c>ShowProgressBar</c> property provides visual feedback on the remaining time for the toast notification based on the <c>Timeout</c> property.
/// </summary>
public bool ShowProgressBar { get; set; }
public bool? ShowProgressBar { get; set; }

/// <summary>
/// When the <c>PauseProgressOnHover</c> property is enabled, the timeout period for the toast notification will be paused when the user hovers the mouse over the toast.
Expand All @@ -35,7 +35,7 @@ public class ToastSettings
/// <summary>
/// The ShowCloseButton property determines whether or not the close button is displayed on the toast notification.
/// </summary>
public bool ShowCloseButton { get; set; }
public bool? ShowCloseButton { get; set; }

/// <summary>
/// The <c>OnClick</c> property is an optional action that is triggered when the user clicks on the toast notification.
Expand Down

0 comments on commit 1f0f1d8

Please sign in to comment.