2026-10-03 12:01:42 +02:00
|
|
|
|
@inherits DComponentBase
|
2026-10-03 12:43:07 +02:00
|
|
|
|
@implements IDisposable
|
2026-10-03 12:01:42 +02:00
|
|
|
|
|
2026-10-03 12:43:07 +02:00
|
|
|
|
@* 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)">
|
2026-10-03 12:01:42 +02:00
|
|
|
|
@ChildContent
|
2026-10-03 12:43:07 +02:00
|
|
|
|
@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>
|
|
|
|
|
|
}
|
2026-10-03 12:01:42 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
@code {
|
2026-10-03 12:43:07 +02:00
|
|
|
|
[CascadingParameter] DCarousel Parent { get; set; }
|
2026-10-03 12:01:42 +02:00
|
|
|
|
[Parameter] public RenderFragment ChildContent { get; set; }
|
2026-10-03 12:43:07 +02:00
|
|
|
|
|
|
|
|
|
|
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);
|
2026-10-03 12:01:42 +02:00
|
|
|
|
}
|