Blazored / Toast

A JavaScript free toast library for Blazor and Razor Component applications
https://blazored.github.io/Toast/
MIT License
654 stars 90 forks source link

[Feature Request] I want to set the global timeout per toast type, in addition to the current setting for all types, for a better user experience. #239

Open szalapski opened 9 months ago

szalapski commented 9 months ago

Is your feature request related to a problem? Please describe. My users don't want "Success" toasts cluttering up the screen for very long, yet they want errors and warnings to show for a longer time so that they can read the message.

Describe the solution you'd like I'd like to be able to set the timeout duration independently and optionally for Success, Info, Warning, and Error, in addition to the global timeout duration. Obviously, if any of these is set, it would override the global timeout duration.

Describe alternatives you've considered I could use the settings lambda to set a custom timeout on every one of hundreds of .ShowSuccess calls, but that doesn't seem wise.

chrissainty commented 6 months ago

@szalapski Apologies for taking so long to reply. Have you tried the pause on hover feature? It would allow your users to hover over any toast they want to keep on the screen and it will only be removed when they move their cursor away from it.

szalapski commented 6 months ago

My users don't often hover and I'm not sure we could train them to do so. For now I've added lots of custom timeouts. Thanks for the response! ☺️

stofte commented 5 months ago

I came here looking for the same thing. Wrapping ToastService seems like a simple enough solution. You can easily add in other type specific settings this way as well. I just need the disabled timeout for errors for now.

public class ToastHelper
{
    private readonly IToastService toastService;

    public ToastHelper(IToastService toastService) => this.toastService = toastService;

    public void ShowError(string msg) => toastService.ShowError(msg, (opts) => opts.DisableTimeout = true);

    public void ShowSuccess(string msg) => toastService.ShowSuccess(msg);
}