ant-design-blazor/components/breadcrumb/BreadcrumbItem.razor

64 lines
1.4 KiB
C#

@namespace AntDesign
@inherits AntDomComponentBase
<li @ref="Ref">
@if (Overlay != null)
{
<Dropdown Placement="@Placement.Bottom">
<Unbound>
<span @ref="context.Current" class="ant-breadcrumb-overlay-link">
<span class="ant-breadcrumb-link" @onclick="@OnClick">
@FormattedChildContent
</span>
<Icon Type="down"></Icon>
</span>
</Unbound>
<Overlay>
@Overlay
</Overlay>
</Dropdown>
}
else
{
<span class="ant-breadcrumb-link" @onclick="@OnClick">
@FormattedChildContent
</span>
}
@if (BreadCrumb?.Separator != null)
{
<span class="ant-breadcrumb-separator">
@BreadCrumb.Separator
</span>
}
</li>
@code {
[Parameter]
public RenderFragment ChildContent { get; set; }
[Parameter]
public RenderFragment Overlay { get; set; }
[Parameter]
public string Href { get; set; }
[Parameter]
public EventCallback<MouseEventArgs> OnClick { get; set; }
[CascadingParameter]
public Breadcrumb BreadCrumb { get; set; }
private RenderFragment FormattedChildContent => Href is null ? ChildContent :@<a href="@Href">@ChildContent</a>;
protected override void OnInitialized()
{
BreadCrumb?.AddOption(new BreadcrumbOption
{
RouterLink = Href,
TitleTemplate = ChildContent
});
base.OnInitialized();
}
}