From da1551d483f82ac4eed28450defa4aae6b7318e5 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Fri, 16 Apr 2021 10:15:31 -0500 Subject: [PATCH 1/8] add pagination component --- lib/Pagination/Pagination.css | 76 ++++++++++++++++++ lib/Pagination/Pagination.js | 84 ++++++++++++++++++++ lib/Pagination/index.js | 1 + lib/Pagination/readme.md | 20 +++++ lib/Pagination/stories/BasicUsage.js | 35 ++++++++ lib/Pagination/stories/Pagination.stories.js | 9 +++ lib/Pagination/tests/Pagination-test.js | 82 +++++++++++++++++++ lib/Pagination/tests/interactor.js | 39 +++++++++ package.json | 1 + translations/stripes-components/en.json | 2 + 10 files changed, 349 insertions(+) create mode 100644 lib/Pagination/Pagination.css create mode 100644 lib/Pagination/Pagination.js create mode 100644 lib/Pagination/index.js create mode 100644 lib/Pagination/readme.md create mode 100644 lib/Pagination/stories/BasicUsage.js create mode 100644 lib/Pagination/stories/Pagination.stories.js create mode 100644 lib/Pagination/tests/Pagination-test.js create mode 100644 lib/Pagination/tests/interactor.js 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..8ce2d610e --- /dev/null +++ b/lib/Pagination/Pagination.js @@ -0,0 +1,84 @@ +import React, { useRef } from 'react'; +import PropTypes from 'prop-types'; +import ReactPaginate from 'react-paginate'; +import uniqueId from 'lodash/uniqueId'; +import classNames from 'classnames'; +import { FormattedMessage } from 'react-intl'; +import Icon from '../Icon'; +import css from './Pagination.css'; + +const propTypes = { + /** Class to be applied to `