Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue #1965]: Reintroduce totalPages to Pagination component #1979

Merged
merged 4 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frontend/src/app/search/SearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export function SearchForm({
handlePageChange={handlePageChange}
showHiddenInput={true}
paginationRef={topPaginationRef}
totalPages={searchResults?.pagination_info?.total_pages}
position={PaginationPosition.Top}
searchResultsLength={searchResults.data.length}
/>
Expand All @@ -107,6 +108,7 @@ export function SearchForm({
<SearchPagination
page={page}
handlePageChange={handlePageChange}
totalPages={searchResults?.pagination_info?.total_pages}
position={PaginationPosition.Bottom}
searchResultsLength={searchResults.data.length}
/>
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/search/SearchPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ interface SearchPaginationProps {
page: number;
handlePageChange: (handlePage: number) => void; // managed in useSearchFormState
paginationRef?: React.RefObject<HTMLInputElement>; // managed in useSearchFormState
totalPages: number;
position: PaginationPosition;
searchResultsLength: number;
}

const MAX_SLOTS = 5;
const MAX_SLOTS = 7;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump max slots to 7


export default function SearchPagination({
showHiddenInput,
page,
handlePageChange,
paginationRef,
totalPages,
position,
searchResultsLength,
}: SearchPaginationProps) {
Expand Down Expand Up @@ -54,6 +56,7 @@ export default function SearchPagination({
)}
<Pagination
pathname="/search"
totalPages={totalPages}
currentPage={page}
maxSlots={MAX_SLOTS}
onClickNext={() => handlePageChange(page + 1)}
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/styles/_uswds-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,10 @@ in the form $setting: value,
"palette-color-system-red-warm"
)
);

// Custom overrides

// Pagination sizing
.usa-pagination .usa-button {
font-size: 22px;
}
Loading