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

38 lines
1.2 KiB
Plaintext
Raw Normal View History

@inherits DComponentBase
@* One button of a DDock: ChildContent is the icon and Text the dock-label under it. Renders an <a> when Href is set,
with aria-current="page" while Active. *@
@if (Href is null)
{
<button @attributes="AdditionalAttributes" type="button" class="@CssClass" disabled="@Disabled" @onclick="OnClick">
@ChildContent
@if (Text is not null)
{
<span class="dock-label">@Text</span>
}
</button>
}
else
{
<a @attributes="AdditionalAttributes" href="@(Disabled ? null : Href)" class="@CssClass"
aria-current="@(Active ? "page" : null)" aria-disabled="@(Disabled ? "true" : null)" tabindex="@(Disabled ? "-1" : null)"
@onclick="OnClick">
@ChildContent
@if (Text is not null)
{
<span class="dock-label">@Text</span>
}
</a>
}
@code {
/// <summary>The icon.</summary>
[Parameter] public RenderFragment ChildContent { get; set; }
[Parameter] public string Text { get; set; }
[Parameter] public bool Active { get; set; }
[Parameter] public bool Disabled { get; set; }
[Parameter] public string Href { get; set; }
[Parameter] public EventCallback<MouseEventArgs> OnClick { get; set; }
string CssClass => Cx(Active ? "dock-active" : null, Class);
}