using Connected.Annotations; using Connected.Utilities; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Routing; namespace Connected.Components; public partial class NavLink : SelectItemBase { protected string Classname => new CssBuilder("mud-nav-item") .AddClass($"mud-ripple", !DisableRipple && !Disabled) .AddClass(Class) .Build(); protected string LinkClassname => new CssBuilder("mud-nav-link") .AddClass($"mud-nav-link-disabled", Disabled) .Build(); protected string IconClassname => new CssBuilder("mud-nav-link-icon") .AddClass($"mud-nav-link-icon-default", IconColor == ThemeColor.Default) .Build(); protected Dictionary Attributes { get => Disabled ? null : new Dictionary() { { "href", Href }, { "target", Target }, { "rel", !string.IsNullOrWhiteSpace(Target) ? "noopener noreferrer" : string.Empty } }; } /// /// Icon to use if set. /// [Parameter] [Category(CategoryTypes.NavMenu.Behavior)] public string Icon { get; set; } /// /// The color of the icon. It supports the theme colors, default value uses the themes drawer icon color. /// [Parameter] [Category(CategoryTypes.NavMenu.Appearance)] public ThemeColor IconColor { get; set; } = ThemeColor.Default; [Parameter] [Category(CategoryTypes.NavMenu.Behavior)] public NavLinkMatch Match { get; set; } = NavLinkMatch.Prefix; [Parameter] [Category(CategoryTypes.NavMenu.ClickAction)] public string Target { get; set; } /// /// User class names when active, separated by space. /// [Parameter] [Category(CategoryTypes.ComponentBase.Common)] public string ActiveClass { get; set; } = "active"; [CascadingParameter] INavigationEventReceiver NavigationEventReceiver { get; set; } protected Task HandleNavigation() { if (!Disabled && NavigationEventReceiver != null) { return NavigationEventReceiver.OnNavigation(); } return Task.CompletedTask; } }