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

Added aria-current attribute to the active page #151

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-js-pagination",
"version": "3.0.3",
"version": "3.0.4",
"description": "Simple, easy to use component for pagination. Compatible with bootstrap paginator stylesheets",
"main": "./dist/Pagination.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class Page extends Component {

return (
<li className={css} onClick={this.handleClick.bind(this)}>
<a className={linkCss} href={href} aria-label={ariaLabel}>
<a className={linkCss} href={href} aria-label={ariaLabel} aria-current={isActive ? 'page' : undefined}>
{pageText}
</a>
</li>
Expand Down
27 changes: 21 additions & 6 deletions src/components/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ export default class Pagination extends React.Component {
activePage: PropTypes.number,
itemsCountPerPage: PropTypes.number,
pageRangeDisplayed: PropTypes.number,
pageAriaLabel: PropTypes.string,
prevPageAriaLabel: PropTypes.string,
prevPageText: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
nextPageAriaLabel: PropTypes.string,
nextPageText: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
lastPageAriaLabel: PropTypes.string,
lastPageText: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
firstPageAriaLabel: PropTypes.string,
firstPageText: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
disabledClass: PropTypes.string,
hideDisabled: PropTypes.bool,
Expand All @@ -39,9 +44,14 @@ export default class Pagination extends React.Component {
itemsCountPerPage: 10,
pageRangeDisplayed: 5,
activePage: 1,
pageAriaLabel: "Go to page number :page",
prevPageAriaLabel: "Go to previous page",
prevPageText: "⟨",
firstPageAriaLabel: "Go to first page",
firstPageText: "«",
nextPageAriaLabel: "Go to next page",
nextPageText: "⟩",
lastPageAriaLabel: "Go to last page",
lastPageText: "»",
innerClass: "pagination",
itemClass: undefined,
Expand Down Expand Up @@ -103,7 +113,12 @@ export default class Pagination extends React.Component {
linkClassNext,
linkClassLast,
hideFirstLastPages,
getPageUrl
getPageUrl,
pageAriaLabel,
firstPageAriaLabel,
prevPageAriaLabel,
nextPageAriaLabel,
lastPageAriaLabel
} = this.props;

const paginationInfo = new paginator(
Expand All @@ -128,7 +143,7 @@ export default class Pagination extends React.Component {
linkClass={linkClass}
activeClass={activeClass}
activeLinkClass={activeLinkClass}
ariaLabel={`Go to page number ${i}`}
ariaLabel={pageAriaLabel.replace(':page', i)}
/>
);
}
Expand All @@ -145,7 +160,7 @@ export default class Pagination extends React.Component {
itemClass={cx(itemClass, itemClassPrev)}
linkClass={cx(linkClass, linkClassPrev)}
disabledClass={disabledClass}
ariaLabel="Go to previous page"
ariaLabel={prevPageAriaLabel}
/>
);

Expand All @@ -161,7 +176,7 @@ export default class Pagination extends React.Component {
itemClass={cx(itemClass, itemClassFirst)}
linkClass={cx(linkClass, linkClassFirst)}
disabledClass={disabledClass}
ariaLabel="Go to first page"
ariaLabel={firstPageAriaLabel}
/>
);

Expand All @@ -177,7 +192,7 @@ export default class Pagination extends React.Component {
itemClass={cx(itemClass, itemClassNext)}
linkClass={cx(linkClass, linkClassNext)}
disabledClass={disabledClass}
ariaLabel="Go to next page"
ariaLabel={nextPageAriaLabel}
/>
);

Expand All @@ -195,7 +210,7 @@ export default class Pagination extends React.Component {
itemClass={cx(itemClass, itemClassLast)}
linkClass={cx(linkClass, linkClassLast)}
disabledClass={disabledClass}
ariaLabel="Go to last page"
ariaLabel={lastPageAriaLabel}
/>
);

Expand Down