@namespace Connected.Components
@inherits UIComponent

@if (Items is null || !Items.Any())
{
    return;
}

<CascadingValue Value="this" IsFixed="true">
    <ul @attributes="CustomAttributes" class=@Classname>
        @if (MaxItems is not null && Collapsed && Items.Count > MaxItems)
        {
            <BreadcrumbLink Item="Items[0]"></BreadcrumbLink>
            <BreadcrumbSeparator></BreadcrumbSeparator>
            <li class="breadcrumbs-expander" @onclick="Expand">
                <Icon Icon="@ExpanderIcon" Size="Size.Small"></Icon>
            </li>
            <BreadcrumbSeparator></BreadcrumbSeparator>
            <BreadcrumbLink Item="Items[Items.Count - 1]"></BreadcrumbLink>
        }
        else
        {
            @for (var i = 0; i < Items.Count; i++)
            {
                var item = Items[i];
                <BreadcrumbLink Item="item"></BreadcrumbLink>

                if (i != Items.Count - 1)
                {
                    <BreadcrumbSeparator></BreadcrumbSeparator>
                }
            }
        }
    </ul>
</CascadingValue>