43 lines
1.1 KiB
Plaintext
43 lines
1.1 KiB
Plaintext
@inject NavigationManager Navigation
|
|
|
|
<footer class="table__paginator">
|
|
<span>
|
|
Showing @FirstItem to @LastItem of @State.TotalItemCount results
|
|
</span>
|
|
<nav class="button-group">
|
|
@if (State.CurrentPage == 1)
|
|
{
|
|
<span class="link link--disabled">Previous</span>
|
|
}
|
|
else
|
|
{
|
|
<a class="link" href="@GetUriForPage(State.CurrentPage - 1)">Previous</a>
|
|
}
|
|
|
|
@if (State.CurrentPage == State.LastPage)
|
|
{
|
|
<span class="link link--disabled">Next</span>
|
|
}
|
|
else
|
|
{
|
|
<a class="link" href="@GetUriForPage(State.CurrentPage + 1)">Next</a>
|
|
}
|
|
</nav>
|
|
</footer>
|
|
|
|
@code {
|
|
[Parameter, EditorRequired]
|
|
public required PaginationState State { get; set; }
|
|
|
|
private int FirstItem => State.TotalItemCount > 0 ? State.Offset + 1 : 0;
|
|
private int LastItem => State.Offset + State.ItemCount;
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
State.ItemCountChanged += (_, _) => StateHasChanged();
|
|
}
|
|
|
|
private string GetUriForPage(int page)
|
|
=> Navigation.GetUriWithQueryParameter("page", page);
|
|
}
|