You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.5 KiB
83 lines
2.5 KiB
//Copyright(c) Alessandro Ghidini.All rights reserved.
|
|
//Changes and improvements Copyright (c) The MudBlazor Team.
|
|
|
|
using Connected.Extensions;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace Connected.Components;
|
|
|
|
public class SnackbarOptions : CommonSnackbarOptions
|
|
{
|
|
public Func<Snackbar, Task> Onclick { get; set; }
|
|
|
|
public string Action { get; set; }
|
|
|
|
public Variant? ActionVariant { get; set; }
|
|
|
|
public ThemeColor ActionColor { get; set; } = ThemeColor.Default;
|
|
|
|
public Severity Severity { get; }
|
|
|
|
public string SnackbarTypeClass { get; set; }
|
|
|
|
public bool CloseAfterNavigation { get; set; }
|
|
|
|
public bool HideIcon { get; set; }
|
|
|
|
public string Icon { get; set; }
|
|
public ThemeColor IconColor { get; set; } = ThemeColor.Inherit;
|
|
public Size IconSize { get; set; } = Size.Medium;
|
|
|
|
public SnackbarDuplicatesBehavior DuplicatesBehavior { get; set; } = SnackbarDuplicatesBehavior.GlobalDefault;
|
|
|
|
/// <summary>
|
|
/// Custom normal icon.
|
|
/// </summary>
|
|
[Parameter] public string NormalIcon { get; set; } = Icons.Material.Outlined.EventNote;
|
|
|
|
/// <summary>
|
|
/// Custom info icon.
|
|
/// </summary>
|
|
[Parameter] public string InfoIcon { get; set; } = Icons.Material.Outlined.Info;
|
|
|
|
/// <summary>
|
|
/// Custom success icon.
|
|
/// </summary>
|
|
[Parameter] public string SuccessIcon { get; set; } = Icons.Custom.Uncategorized.AlertSuccess;
|
|
|
|
/// <summary>
|
|
/// Custom warning icon.
|
|
/// </summary>
|
|
[Parameter] public string WarningIcon { get; set; } = Icons.Material.Outlined.ReportProblem;
|
|
|
|
/// <summary>
|
|
/// Custom error icon.
|
|
/// </summary>
|
|
[Parameter] public string ErrorIcon { get; set; } = Icons.Material.Filled.ErrorOutline;
|
|
|
|
public SnackbarOptions(Severity severity, CommonSnackbarOptions options) : base(options)
|
|
{
|
|
Severity = severity;
|
|
|
|
SnackbarTypeClass = $"mud-alert-{SnackbarVariant.ToDescriptionString()}-{severity.ToDescriptionString()}";
|
|
|
|
if (SnackbarVariant != Variant.Filled)
|
|
{
|
|
SnackbarTypeClass += BackgroundBlurred ? " mud-snackbar-blurred" : " mud-snackbar-surface";
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(Icon))
|
|
{
|
|
Icon = Severity switch
|
|
{
|
|
Severity.Normal => NormalIcon,
|
|
Severity.Info => InfoIcon,
|
|
Severity.Success => SuccessIcon,
|
|
Severity.Warning => WarningIcon,
|
|
Severity.Error => ErrorIcon,
|
|
_ => throw new ArgumentOutOfRangeException(nameof(Severity)),
|
|
};
|
|
}
|
|
}
|
|
}
|