Files
decePubClient/Components/Daisy/DataDisplay/DCarouselItem.razor
T

28 lines
1.1 KiB
Plaintext
Raw Normal View History

@inherits DComponentBase
@implements IDisposable
@* One slide of a DCarousel. It registers with the carousel for its id and, with ShowNavigation, draws the
previous/next links over itself. *@
<div @attributes="AdditionalAttributes" id="@Id" class="@Cx("carousel-item", HasNavigation ? "relative" : null, Class)">
@ChildContent
@if (HasNavigation)
{
<div class="absolute inset-x-2 top-1/2 flex -translate-y-1/2 justify-between">
<a href="@Parent.Link(Index - 1)" class="btn btn-circle btn-sm" aria-label="@Parent.PreviousText">❮</a>
<a href="@Parent.Link(Index + 1)" class="btn btn-circle btn-sm" aria-label="@Parent.NextText">❯</a>
</div>
}
</div>
@code {
[CascadingParameter] DCarousel Parent { get; set; }
[Parameter] public RenderFragment ChildContent { get; set; }
int Index => Parent?.IndexOf(this) ?? -1;
string Id => Parent is null ? null : Parent.SlideId(Index);
bool HasNavigation => Parent is { ShowNavigation: true, Count: > 1 };
protected override void OnInitialized() => Parent?.Add(this);
public void Dispose() => Parent?.Remove(this);
}