From e593354cb4811aaba1fb9dd04f8477b26cc59411 Mon Sep 17 00:00:00 2001 From: aleidk Date: Sun, 5 Nov 2023 10:32:49 -0300 Subject: [PATCH] Update pagination in table. Add getPaginationRage to usePagination hook. Use the getPaginationRage to create dynamic buttons in the table. --- src/assets/style/global.css | 9 ++++ src/components/Table/Table.tsx | 16 ++++++- src/hooks/usePagination.tsx | 79 +++++++++++++++++++++++----------- src/pages/games/index.astro | 2 +- 4 files changed, 80 insertions(+), 26 deletions(-) diff --git a/src/assets/style/global.css b/src/assets/style/global.css index faf6162..feaa63d 100644 --- a/src/assets/style/global.css +++ b/src/assets/style/global.css @@ -68,3 +68,12 @@ td { border: 1px solid white; text-align: center; } + +.btn { + padding: var(--prj-spacing-1); +} + +.btn-primary { + background-color: var(--prj--primary-bg); + color: var(--prj--primary-text); +} diff --git a/src/components/Table/Table.tsx b/src/components/Table/Table.tsx index 382d85d..8c05ec6 100644 --- a/src/components/Table/Table.tsx +++ b/src/components/Table/Table.tsx @@ -43,8 +43,9 @@ export default function Table({ data, headers }: Props): JSX.Element { }); }, [data, filters]); - const { items, changeOffset } = usePagination({ + const { items, changeOffset, getPaginationRange } = usePagination({ items: filteredItems, + limit: 10, }); const handleUpdateFilters = ( @@ -179,6 +180,19 @@ export default function Table({ data, headers }: Props): JSX.Element { > Prev + + {getPaginationRange().map((item) => ( + + ))} +