Files
decePubClient/Components/Daisy/Navigation/DMenuItem.razor
T

29 lines
1.0 KiB
Plaintext
Raw Normal View History

@inherits DComponentBase
@* One item of a DMenu: an <li> holding an <a> when Href is set, otherwise a <button>. class and other attributes go
on the <a>/<button>, which also carries menu-active; menu-disabled goes on the <li>, as daisyUI expects. *@
<li class="@(Disabled ? "menu-disabled" : null)">
@if (Href is null)
{
<button @attributes="AdditionalAttributes" type="button" class="@CssClass" disabled="@Disabled" @onclick="OnClick">
@ChildContent
</button>
}
else
{
<a @attributes="AdditionalAttributes" href="@(Disabled ? null : Href)" class="@CssClass"
aria-disabled="@(Disabled ? "true" : null)" tabindex="@(Disabled ? "-1" : null)" @onclick="OnClick">
@ChildContent
</a>
}
</li>
@code {
[Parameter] public RenderFragment ChildContent { get; set; }
[Parameter] public string Href { get; set; }
[Parameter] public bool Active { get; set; }
[Parameter] public bool Disabled { get; set; }
[Parameter] public EventCallback<MouseEventArgs> OnClick { get; set; }
string CssClass => Cx(Active ? "menu-active" : null, Class);
}