mirror of
https://github.com/radzenhq/radzen-blazor.git
synced 2026-02-04 05:35:44 +00:00
157 lines
4.9 KiB
C#
157 lines
4.9 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Radzen.Blazor
|
|
{
|
|
/// <summary>
|
|
/// A menu item component used within RadzenProfileMenu to define individual navigation or action items.
|
|
/// RadzenProfileMenuItem represents one clickable item in a profile menu dropdown with support for icons, navigation, and custom content.
|
|
/// Used inside RadzenProfileMenu to create user profile dropdown menus. Each item can navigate to a page (via Path), trigger an action (via click event), or display custom content (via Template).
|
|
/// Common uses in profile menus include account settings, user profile page, logout/sign out, preferences, and help/documentation.
|
|
/// Items support icons, images, text, and custom templates for flexible rendering.
|
|
/// </summary>
|
|
/// <example>
|
|
/// Profile menu items in a profile menu:
|
|
/// <code>
|
|
/// <RadzenProfileMenu>
|
|
/// <Template>
|
|
/// <RadzenIcon Icon="account_circle" /> John Doe
|
|
/// </Template>
|
|
/// <ChildContent>
|
|
/// <RadzenProfileMenuItem Text="Profile" Icon="person" Path="/profile" />
|
|
/// <RadzenProfileMenuItem Text="Settings" Icon="settings" Path="/settings" />
|
|
/// <RadzenProfileMenuItem Text="Logout" Icon="logout" Value="logout" />
|
|
/// </ChildContent>
|
|
/// </RadzenProfileMenu>
|
|
/// </code>
|
|
/// </example>
|
|
public partial class RadzenProfileMenuItem : RadzenComponent
|
|
{
|
|
/// <inheritdoc />
|
|
protected override string GetComponentCssClass()
|
|
{
|
|
return "rz-navigation-item";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the text.
|
|
/// </summary>
|
|
/// <value>The text.</value>
|
|
[Parameter]
|
|
public string ImageAlternateText { get; set; } = "image";
|
|
|
|
/// <summary>
|
|
/// Gets or sets the target.
|
|
/// </summary>
|
|
/// <value>The target.</value>
|
|
[Parameter]
|
|
public string? Target { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the path.
|
|
/// </summary>
|
|
/// <value>The path.</value>
|
|
[Parameter]
|
|
public string? Path { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the navigation link match.
|
|
/// </summary>
|
|
/// <value>The navigation link match.</value>
|
|
[Parameter]
|
|
public NavLinkMatch Match { get; set; } = NavLinkMatch.Prefix;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the icon.
|
|
/// </summary>
|
|
/// <value>The icon.</value>
|
|
[Parameter]
|
|
public string? Icon { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the icon color.
|
|
/// </summary>
|
|
/// <value>The icon color.</value>
|
|
[Parameter]
|
|
public string? IconColor { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the image.
|
|
/// </summary>
|
|
/// <value>The image.</value>
|
|
[Parameter]
|
|
public string? Image { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the text.
|
|
/// </summary>
|
|
/// <value>The text.</value>
|
|
[Parameter]
|
|
public string? Text { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the value.
|
|
/// </summary>
|
|
/// <value>The value.</value>
|
|
[Parameter]
|
|
public string? Value { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the template.
|
|
/// </summary>
|
|
/// <value>The template.</value>
|
|
[Parameter]
|
|
public RenderFragment? Template { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the menu.
|
|
/// </summary>
|
|
/// <value>The menu.</value>
|
|
[CascadingParameter]
|
|
public RadzenProfileMenu? Menu { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// Handles the click event.
|
|
/// </summary>
|
|
/// <param name="args">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
|
public async System.Threading.Tasks.Task OnClick(MouseEventArgs args)
|
|
{
|
|
if (Menu != null)
|
|
{
|
|
await Menu.Click.InvokeAsync(this);
|
|
}
|
|
}
|
|
|
|
RadzenProfileMenu? _parent;
|
|
/// <summary>
|
|
/// Gets or sets the parent.
|
|
/// </summary>
|
|
/// <value>The parent.</value>
|
|
[CascadingParameter]
|
|
public RadzenProfileMenu? Parent
|
|
{
|
|
get
|
|
{
|
|
return _parent;
|
|
}
|
|
set
|
|
{
|
|
if (_parent != value)
|
|
{
|
|
_parent = value;
|
|
|
|
_parent?.AddItem(this);
|
|
}
|
|
}
|
|
}
|
|
|
|
internal string GetItemCssClass()
|
|
{
|
|
return $"{GetCssClass()} {(Parent?.IsFocused(this) == true ? "rz-state-focused" : "")}".Trim();
|
|
}
|
|
}
|
|
}
|