diff --git a/index.js b/index.js index aa4e29d27..1c7f48ecb 100644 --- a/index.js +++ b/index.js @@ -130,6 +130,7 @@ export { export { default as FilterControlGroup } from './lib/FilterControlGroup'; export { default as FilterPaneSearch } from './lib/FilterPaneSearch'; export { default as ExportCsv } from './lib/ExportCsv'; +export { default as Pagination } from './lib/Pagination'; export { default as exportToCsv } from './lib/ExportCsv/exportToCsv'; /* utilities */ diff --git a/lib/Pagination/Pagination.css b/lib/Pagination/Pagination.css new file mode 100644 index 000000000..c46b7d82b --- /dev/null +++ b/lib/Pagination/Pagination.css @@ -0,0 +1,76 @@ +@import '../variables.css'; + +/** +* Default styling +*/ + +.pagination { + display: flex; + list-style: none; + padding: 4px 0; + margin: 0; + + &.fillWidth { + width: 100%; + justify-content: space-between; + } + + & .paginationItem { + padding: 0 2px; + margin: 0 1px; + } +} + +.paginationLink { + composes: button from "../Button/Button.css"; + padding: 0 var(--gutter-static-two-thirds, 8px); + margin: 0; + + &[aria-disabled=true] { + color: var(--color-text-p2); + transition: opacity ease-in-out 500ms; + pointer-events: none; + } + + &.numberLink { + min-width: 1.72rem; + padding: 0 4px; + margin: 0; + } + + &:visited { + color: inherit; + } + + &::before { + border-radius: 999px; + } + + /** + * Button Style: Default + */ + + &.default { + background-color: transparent; + border: 1px solid var(--primary); + color: var(--primary); + + & :global .stripes__icon { + fill: var(--primary); + } + } + + /** + * Button style primary + */ + + &.primary { + background-color: var(--primary); + border: 1px solid var(--primary); + color: #fff; + + &:hover { + opacity: 0.9; + } + } +} diff --git a/lib/Pagination/Pagination.js b/lib/Pagination/Pagination.js new file mode 100644 index 000000000..0ee09e7bd --- /dev/null +++ b/lib/Pagination/Pagination.js @@ -0,0 +1,91 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import ReactPaginate from 'react-paginate'; +import { FormattedMessage } from 'react-intl'; +import Icon from '../Icon'; +import css from './Pagination.css'; + +// < # ... # # # ... # > +// |_| |___| |_____| |___| |_| +// OUTER BREAK CENTER BREAK OUTER + +const MINIMAL_DISPLAY_THRESHOLD = 6; +const MINIMAL_DISPLAY_COUNT = 3; +const EXTENDED_DISPLAY_COUNT = 6; +const MAX_EXTENDED_OUTER_PAGES = 1; + +const propTypes = { + /** Class to be applied to `