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

40 lines
1.2 KiB
Plaintext
Raw Normal View History

@inherits DComponentBase
@* daisyUI Link: https://daisyui.com/components/link/ . Without Href it renders a <button> styled as a link, so an
OnClick-only link stays keyboard-reachable. *@
@if (Href is null)
{
<button @attributes="AdditionalAttributes" type="button" class="@CssClass" @onclick="OnClick">
@ChildContent
</button>
}
else
{
<a @attributes="AdditionalAttributes" href="@Href" class="@CssClass" @onclick="OnClick">
@ChildContent
</a>
}
@code {
[Parameter] public RenderFragment ChildContent { get; set; }
[Parameter] public string Href { get; set; }
[Parameter] public DColor Color { get; set; }
/// <summary>Underline only on hover (link-hover).</summary>
[Parameter] public bool Hover { get; set; }
[Parameter] public EventCallback<MouseEventArgs> OnClick { get; set; }
string CssClass => Cx("link", ColorClass, Hover ? "link-hover" : null, Class);
string ColorClass => Color switch
{
DColor.Neutral => "link-neutral",
DColor.Primary => "link-primary",
DColor.Secondary => "link-secondary",
DColor.Accent => "link-accent",
DColor.Info => "link-info",
DColor.Success => "link-success",
DColor.Warning => "link-warning",
DColor.Error => "link-error",
_ => null
};
}