Skip to content

Commit

Permalink
Merge pull request #132 from ConductionNL/feature/OP-57/pagination-re…
Browse files Browse the repository at this point in the history
…factor

REFACTOR Pagination ariaLabels
  • Loading branch information
lencodes authored Oct 16, 2023
2 parents 0b17426 + 62f4b0d commit f956cbb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- **Version 2.2 (breaking changes from 2.1.x)**

- 2.2.17: Refactor Pagination to include aria labels and make aria label required on texarea, input and select components.
- 2.2.15/2.2.16: Added more NLDS options to Pagination.
- 2.2.13/2.2.14:
- Updated Textarea and all Input components to allow aria-label.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@conduction/components",
"version": "2.2.16",
"version": "2.2.17",
"description": "React (Gatsby) components used within the Conduction Skeleton Application (and its implementations)",
"main": "lib/index.js",
"scripts": {
Expand Down
20 changes: 17 additions & 3 deletions src/components/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,21 @@ interface PaginationProps {
totalPages: number;
currentPage: number;
setCurrentPage: React.Dispatch<React.SetStateAction<number>>;
ariaLabels: {
nextPage: string;
previousPage: string;
page: string;
};
layoutClassName?: string;
}

export const Pagination: React.FC<PaginationProps> = ({ totalPages, currentPage, setCurrentPage, layoutClassName }) => {
export const Pagination: React.FC<PaginationProps> = ({
totalPages,
currentPage,
setCurrentPage,
ariaLabels,
layoutClassName,
}) => {
if (totalPages < 1) return <></>; // no pages available

return (
Expand All @@ -31,13 +42,16 @@ export const Pagination: React.FC<PaginationProps> = ({ totalPages, currentPage,
breakLabel="..."
nextClassName={styles.next}
previousClassName={styles.previous}
nextAriaLabel={ariaLabels.nextPage}
previousAriaLabel={ariaLabels.previousPage}
ariaLabelBuilder={(currentPage) => `${ariaLabels.page} ${currentPage}`}
nextLabel={
<Button className={styles.button}>
<Button tabIndex={-1} className={styles.button}>
<FontAwesomeIcon icon={faChevronRight} />
</Button>
}
previousLabel={
<Button className={styles.button}>
<Button tabIndex={-1} className={styles.button}>
<FontAwesomeIcon icon={faChevronLeft} />
</Button>
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/formFields/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ErrorMessage } from "./errorMessage/ErrorMessage";

export interface IInputProps {
name: string;
ariaLabel?: string;
ariaLabel: string;
disabled?: boolean;
defaultValue?: string;
icon?: JSX.Element;
Expand Down
2 changes: 1 addition & 1 deletion src/components/formFields/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface ISelectProps {
control: Control<FieldValues, any>;
options: { label: string; value: string }[];
name: string;
ariaLabel?: string;
ariaLabel: string;
id?: string;
defaultValue?: any;
disabled?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/components/formFields/textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Textarea as UtrechtTextarea } from "@utrecht/component-library-react/di

export interface ITextAreaProps {
name: string;
ariaLabel?: string;
ariaLabel: string;
disabled?: boolean;
defaultValue?: string;
hideErrorMessage?: boolean;
Expand Down

0 comments on commit f956cbb

Please sign in to comment.