//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 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; /// /// Custom normal icon. /// [Parameter] public string NormalIcon { get; set; } = Icons.Material.Outlined.EventNote; /// /// Custom info icon. /// [Parameter] public string InfoIcon { get; set; } = Icons.Material.Outlined.Info; /// /// Custom success icon. /// [Parameter] public string SuccessIcon { get; set; } = Icons.Custom.Uncategorized.AlertSuccess; /// /// Custom warning icon. /// [Parameter] public string WarningIcon { get; set; } = Icons.Material.Outlined.ReportProblem; /// /// Custom error icon. /// [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)), }; } } }