Skip to content

Commit

Permalink
Docs update for MaxToastCount
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissainty committed Oct 8, 2021
1 parent c65b71d commit 2989413
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Toasts are configured using parameters on the `<BlazoredToasts />` component. Th
- ShowProgressBar (Default: false)
- ShowCloseButton (Default: true)
- CloseButtonContent (provide custom close button)
- MaxToastCount (Default: `int.MaxValue`)

By default, you don't need to provide any settings everything will just work. But if you want to add icons to toasts or override the default styling then you can use the options above to do that.

Expand Down Expand Up @@ -168,6 +169,9 @@ You can display a progress bar which gives a visual indicator of the time remain
### Remove Toasts When Navigating
If you wish to clear any visible toasts when the user navigates to a new page you can enable the `RemoveToastsOnNavigation` parameter. Setting this to true will remove any visible toasts whenever the `LocationChanged` event fires.

### Limiting number of toasts shown at once
If you want to limit the number of toasts displayed at any given time, you can set the `MaxToastCount` parameter. For example, if the value is set to *3* only three toast instances will be displayed. Any additional toasts that are triggered will be held in a queue and will be displayed as older toasts time out.

### Custom Component
You can call the `ShowToast` method passing the type of component you want the toast to display.

Expand Down
12 changes: 6 additions & 6 deletions src/Blazored.Toast/BlazoredToasts.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public partial class BlazoredToasts
[Parameter] public string ErrorIcon { get; set; }
[Parameter] public ToastPosition Position { get; set; } = ToastPosition.TopRight;
[Parameter] public int Timeout { get; set; } = 5;
[Parameter] public int MaxItemsShown { get; set; } = int.MaxValue;
[Parameter] public int MaxToastCount { get; set; } = int.MaxValue;
[Parameter] public bool RemoveToastsOnNavigation { get; set; }
[Parameter] public bool ShowProgressBar { get; set; }
[Parameter] public RenderFragment CloseButtonContent { get; set; }
Expand Down Expand Up @@ -95,19 +95,19 @@ private ToastSettings BuildToastSettings(ToastLevel level, RenderFragment messag
{
case ToastLevel.Error:
return new ToastSettings(string.IsNullOrWhiteSpace(heading) ? "Error" : heading, message, IconType,
"blazored-toast-error", ErrorClass, ErrorIcon, ShowProgressBar, MaxItemsShown, onclick);
"blazored-toast-error", ErrorClass, ErrorIcon, ShowProgressBar, MaxToastCount, onclick);

case ToastLevel.Info:
return new ToastSettings(string.IsNullOrWhiteSpace(heading) ? "Info" : heading, message, IconType,
"blazored-toast-info", InfoClass, InfoIcon, ShowProgressBar, MaxItemsShown, onclick);
"blazored-toast-info", InfoClass, InfoIcon, ShowProgressBar, MaxToastCount, onclick);

case ToastLevel.Success:
return new ToastSettings(string.IsNullOrWhiteSpace(heading) ? "Success" : heading, message, IconType,
"blazored-toast-success", SuccessClass, SuccessIcon, ShowProgressBar, MaxItemsShown, onclick);
"blazored-toast-success", SuccessClass, SuccessIcon, ShowProgressBar, MaxToastCount, onclick);

case ToastLevel.Warning:
return new ToastSettings(string.IsNullOrWhiteSpace(heading) ? "Warning" : heading, message, IconType,
"blazored-toast-warning", WarningClass, WarningIcon, ShowProgressBar, MaxItemsShown, onclick);
"blazored-toast-warning", WarningClass, WarningIcon, ShowProgressBar, MaxToastCount, onclick);
}

throw new InvalidOperationException();
Expand All @@ -120,7 +120,7 @@ private void ShowToast(ToastLevel level, RenderFragment message, string heading,
var settings = BuildToastSettings(level, message, heading, onClick);
var toast = new ToastInstance(settings);

if (ToastList.Count < MaxItemsShown)
if (ToastList.Count < MaxToastCount)
{
ToastList.Add(toast);

Expand Down

0 comments on commit 2989413

Please sign in to comment.