All files / molecule/pagination/src PageButton.js

83.33% Statements 5/6
100% Branches 0/0
50% Functions 1/2
83.33% Lines 5/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35              1x 20x     20x             1x                         1x      
import PropTypes from 'prop-types'
 
import AtomButton from '@s-ui/react-atom-button'
 
import {isValidPage} from './customPropTypes/index.js'
import {BASE_CLASS} from './settings.js'
 
const PageButton = ({onSelectPage, page, design, color, ...props}) => {
  const _onSelectPage = e => {
    onSelectPage(e, {page})
  }
  return (
    <li className={`${BASE_CLASS}-item`}>
      <AtomButton onClick={_onSelectPage} design={design} color={color} {...props} />
    </li>
  )
}
 
PageButton.propTypes = {
  /** Callback that will be called with (event, page) on each page button click */
  onSelectPage: PropTypes.func,
  /** Current page selected */
  page: isValidPage,
  /** Design to be used for the page button. Design types 'solid', 'outline' or 'flat' */
  design: PropTypes.string,
  /** Button color */
  color: PropTypes.string,
  /** Factory used to create navigation links */
  linkFactory: PropTypes.func
}
 
PageButton.displayName = 'MoleculePaginationPageButton'
 
export default PageButton