From cda15fd21b656078a30107e11b0e925914f65761 Mon Sep 17 00:00:00 2001 From: albx Date: Sat, 7 Mar 2026 12:08:17 +0100 Subject: [PATCH 01/18] #8 - add standard pagination component --- .../Components/Pagination/BitPageItem.razor | 5 ++ .../Pagination/BitPageItem.razor.cs | 26 +++++++++ .../Components/Pagination/BitPagination.razor | 28 +++++++++ .../Pagination/BitPagination.razor.cs | 57 +++++++++++++++++++ .../BitPaginationTest.Rendering.razor | 35 ++++++++++++ 5 files changed, 151 insertions(+) create mode 100644 src/BitBlazor/Components/Pagination/BitPageItem.razor create mode 100644 src/BitBlazor/Components/Pagination/BitPageItem.razor.cs create mode 100644 src/BitBlazor/Components/Pagination/BitPagination.razor create mode 100644 src/BitBlazor/Components/Pagination/BitPagination.razor.cs create mode 100644 tests/BitBlazor.Test/Components/Pagination/BitPaginationTest.Rendering.razor diff --git a/src/BitBlazor/Components/Pagination/BitPageItem.razor b/src/BitBlazor/Components/Pagination/BitPageItem.razor new file mode 100644 index 0000000..d7d924c --- /dev/null +++ b/src/BitBlazor/Components/Pagination/BitPageItem.razor @@ -0,0 +1,5 @@ +@namespace BitBlazor.Components + +
  • + @Page +
  • diff --git a/src/BitBlazor/Components/Pagination/BitPageItem.razor.cs b/src/BitBlazor/Components/Pagination/BitPageItem.razor.cs new file mode 100644 index 0000000..23153df --- /dev/null +++ b/src/BitBlazor/Components/Pagination/BitPageItem.razor.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Components; + +namespace BitBlazor.Components; + +public partial class BitPageItem +{ + [CascadingParameter] + BitPagination Parent { get; set; } = default!; + + [Parameter] + public int Page { get; set; } + + private IDictionary attributes = new Dictionary(); + + protected override void OnParametersSet() + { + if (Page == Parent.Page) + { + attributes["aria-current"] = "page"; + } + else + { + attributes.Remove("aria-current"); + } + } +} diff --git a/src/BitBlazor/Components/Pagination/BitPagination.razor b/src/BitBlazor/Components/Pagination/BitPagination.razor new file mode 100644 index 0000000..beead5a --- /dev/null +++ b/src/BitBlazor/Components/Pagination/BitPagination.razor @@ -0,0 +1,28 @@ +@namespace BitBlazor.Components + +@inherits BitComponentBase + + diff --git a/src/BitBlazor/Components/Pagination/BitPagination.razor.cs b/src/BitBlazor/Components/Pagination/BitPagination.razor.cs new file mode 100644 index 0000000..6fed3de --- /dev/null +++ b/src/BitBlazor/Components/Pagination/BitPagination.razor.cs @@ -0,0 +1,57 @@ +using BitBlazor.Core; +using Microsoft.AspNetCore.Components; + +namespace BitBlazor.Components; + +/// +/// Represents a component that provides pagination functionality for navigating large data sets in a user interface. +/// +/// +/// Use this component to enable users to move between pages of data efficiently. +/// +public partial class BitPagination : BitComponentBase +{ + /// + /// Gets or sets the total number of pages available for pagination. + /// + /// + /// This property must be set before rendering the component to ensure correct pagination behavior. + /// The value should be a positive integer representing the total number of pages in the data set. + /// + [Parameter] + [EditorRequired] + public int NumberOfPages { get; set; } = 1; + + [Parameter] + public int Page { get; set; } = 1; + + [Parameter] + public EventCallback PageChanged { get; set; } + + /// + /// Gets or sets the component's description which will be put in the aria-label attribute of the main container + /// + [Parameter] + [EditorRequired] + public string Description { get; set; } = string.Empty; + + /// + /// Gets or sets the label text displayed for the previous page navigation link. + /// + /// + /// Set this property to customize the text shown for the previous page button in the pagination component. + /// The default value is "previous page". + /// + [Parameter] + public string PreviousPageLabel { get; set; } = "previous page"; + + /// + /// Gets or sets the label text displayed for the next page navigation link. + /// + /// + /// Set this property to customize the text shown to users for the next page button in the pagination component. + /// The default value is "next page". + /// + [Parameter] + public string NextPageLabel { get; set; } = "next page"; +} diff --git a/tests/BitBlazor.Test/Components/Pagination/BitPaginationTest.Rendering.razor b/tests/BitBlazor.Test/Components/Pagination/BitPaginationTest.Rendering.razor new file mode 100644 index 0000000..8222565 --- /dev/null +++ b/tests/BitBlazor.Test/Components/Pagination/BitPaginationTest.Rendering.razor @@ -0,0 +1,35 @@ +@inherits BunitContext + +@code { + [Fact] + public void BitPagination_Should_Render_Correctly() + { + int currentPage = 1; + + var component = Render( + @); + + component.MarkupMatches( + @); + } +} From 551b6c0faaa0ec631607fba0a722d1a84c7b3490 Mon Sep 17 00:00:00 2001 From: Alberto Mori Date: Mon, 9 Mar 2026 22:28:43 +0100 Subject: [PATCH 02/18] #8 - pagination alignment --- .../Components/Pagination/BitPagination.razor | 2 +- .../Pagination/BitPagination.razor.cs | 38 +++++++++++++++++++ .../Pagination/PaginationAlignment.cs | 26 +++++++++++++ .../BitPaginationTest.Rendering.razor | 36 ++++++++++++++++++ 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/BitBlazor/Components/Pagination/PaginationAlignment.cs diff --git a/src/BitBlazor/Components/Pagination/BitPagination.razor b/src/BitBlazor/Components/Pagination/BitPagination.razor index beead5a..e6c7764 100644 --- a/src/BitBlazor/Components/Pagination/BitPagination.razor +++ b/src/BitBlazor/Components/Pagination/BitPagination.razor @@ -2,7 +2,7 @@ @inherits BitComponentBase -