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

Supports inline style objects for active element #265

Open
wants to merge 1 commit 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
26 changes: 26 additions & 0 deletions __tests__/PaginationBoxView-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,32 @@ describe('Test custom props', () => {
});
});

describe('activeStyle', () => {
it('should use activeStyle prop when defined', () => {
const pagination = ReactTestUtils.renderIntoDocument(
<PaginationBoxView
activeStyle={{backgroundColor: 'red', color: 'rgb(255, 255, 255)'}}
/>
);

const pageItem = ReactDOM.findDOMNode(pagination).querySelector(
'li:nth-child(3) a'
);
ReactTestUtils.Simulate.click(pageItem);

expect(
ReactDOM.findDOMNode(pagination).querySelector(
'li:nth-child(3) a'
).style
).toHaveProperty('background-color', 'red');
expect(
ReactDOM.findDOMNode(pagination).querySelector(
'li:nth-child(3) a'
).style
).toHaveProperty('color', 'rgb(255, 255, 255)');
});
});

describe('pageClassName/activeClassName', () => {
it('should use the pageClassName prop when defined', () => {
const pagination = ReactTestUtils.renderIntoDocument(
Expand Down
5 changes: 5 additions & 0 deletions react_components/PageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
const PageView = props => {
let pageClassName = props.pageClassName;
let pageLinkClassName = props.pageLinkClassName;
let pageLinkStyle = props.pageLinkStyle;

const onClick = props.onClick;
const href = props.href;
Expand Down Expand Up @@ -35,6 +36,8 @@ const PageView = props => {
} else {
pageLinkClassName = props.activeLinkClassName;
}

pageLinkStyle = props.activeStyle;
}

return (
Expand All @@ -43,6 +46,7 @@ const PageView = props => {
onClick={onClick}
role="button"
className={pageLinkClassName}
style={pageLinkStyle}
href={href}
tabIndex="0"
aria-label={ariaLabel}
Expand All @@ -60,6 +64,7 @@ PageView.propTypes = {
selected: PropTypes.bool.isRequired,
pageClassName: PropTypes.string,
pageLinkClassName: PropTypes.string,
activeStyle: PropTypes.object,
activeClassName: PropTypes.string,
activeLinkClassName: PropTypes.string,
extraAriaContext: PropTypes.string,
Expand Down
4 changes: 4 additions & 0 deletions react_components/PaginationBoxView.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class PaginationBoxView extends Component {
pageClassName: PropTypes.string,
pageLinkClassName: PropTypes.string,
activeClassName: PropTypes.string,
activeStyle: PropTypes.object,
activeLinkClassName: PropTypes.string,
previousClassName: PropTypes.string,
nextClassName: PropTypes.string,
Expand All @@ -39,6 +40,7 @@ export default class PaginationBoxView extends Component {
pageRangeDisplayed: 2,
marginPagesDisplayed: 3,
activeClassName: 'selected',
activeStyle: {},
previousClassName: 'previous',
nextClassName: 'next',
previousLabel: 'Previous',
Expand Down Expand Up @@ -192,6 +194,7 @@ export default class PaginationBoxView extends Component {
pageClassName,
pageLinkClassName,
activeClassName,
activeStyle,
activeLinkClassName,
extraAriaContext,
} = this.props;
Expand All @@ -204,6 +207,7 @@ export default class PaginationBoxView extends Component {
pageClassName={pageClassName}
pageLinkClassName={pageLinkClassName}
activeClassName={activeClassName}
activeStyle={activeStyle}
activeLinkClassName={activeLinkClassName}
extraAriaContext={extraAriaContext}
href={this.hrefBuilder(index)}
Expand Down