From 62bec3b6714bde02513ee1db717147640b6970eb Mon Sep 17 00:00:00 2001 From: Edouard Wautier <4435185+Duncid@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:08:27 +0100 Subject: [PATCH] PaginatedCitation update --- .../src/components/PaginatedCitationsGrid.tsx | 20 ++++++------------- .../PaginatedCitationsGrid.stories.tsx | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/sparkle/src/components/PaginatedCitationsGrid.tsx b/sparkle/src/components/PaginatedCitationsGrid.tsx index ea0ebb67aff3..c935dfee9cea 100644 --- a/sparkle/src/components/PaginatedCitationsGrid.tsx +++ b/sparkle/src/components/PaginatedCitationsGrid.tsx @@ -5,6 +5,7 @@ import React from "react"; import { Citation, CitationDescription, + CitationGrid, CitationIcons, CitationIndex, CitationTitle, @@ -26,37 +27,28 @@ interface PaginatedCitationsGridProps { export function PaginatedCitationsGrid({ items, - maxItemsPerPage = 9, + maxItemsPerPage = 12, }: PaginatedCitationsGridProps) { const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: maxItemsPerPage, }); - const cols = 3; - const rows = Math.ceil(Math.min(maxItemsPerPage, items.length) / cols); if (items.length === 0) { return null; } const { pageIndex, pageSize } = pagination; - // Calculate start index. const startIndex = pageIndex * pageSize; - // Slice items for current page. + const paginatedItems = items.slice(startIndex, startIndex + pageSize); return (
-
+ {paginatedItems.map((d, idx) => { return ( - + {idx} {d.icon} @@ -66,7 +58,7 @@ export function PaginatedCitationsGrid({ ); })} -
+
{ return ( <>
- +
);