Skip to content

Conversation

@geotrev
Copy link
Contributor

@geotrev geotrev commented Feb 20, 2024

Description

  • Introduces OffsetPagination (renamed Pagination) with API and accessibility improvements.
  • Migration doc updated

Detail

  • transformPageProps prop has been removed
  • labels prop added to more simply customize pagination element labels
  • container-pagination removed (no arrow key navigation removed + hook-provided attributes restored in its place)
  • HTML structure & accessibility improvements:
    • Wrapping nav tag with translatable aria-label.
    • Translatable aria-label recommended for ellipsis/page gap element
    • List items contain buttons
    • Numbered page elements now indicated with aria-current="page"
    • Numbered page elements consistently labeled as Page X (current word removed).

Checklist

  • 👌 design updates will be Garden Designer approved (add the designer as a reviewer)
  • 🌐 demo is up-to-date (npm start)
  • ⬅️ renders as expected with reversed (RTL) direction
  • 🤘 renders as expected with Bedrock CSS (?bedrock)
  • 💂‍♂️ includes new unit tests. Maintain existing coverage (always >= 96%)
  • ♿ tested for WCAG 2.1 AA accessibility compliance
  • 📝 tested in Chrome, Firefox, Safari, and Edge

@geotrev geotrev self-assigned this Feb 20, 2024
@geotrev geotrev changed the base branch from main to next February 20, 2024 23:08
@geotrev geotrev force-pushed the george/pagination-cleanup branch from 4090241 to 78beead Compare February 20, 2024 23:13
@coveralls
Copy link

coveralls commented Feb 20, 2024

Coverage Status

coverage: 96.065% (-0.04%) from 96.106%
when pulling c4cef1b on george/pagination-cleanup
into 28b5fa6 on next.

@geotrev geotrev force-pushed the george/pagination-cleanup branch from 78beead to 10b9bda Compare February 21, 2024 15:04
@geotrev geotrev marked this pull request as ready for review February 21, 2024 17:46
@geotrev geotrev requested a review from a team as a code owner February 21, 2024 17:46
@geotrev geotrev force-pushed the george/pagination-cleanup branch from 10b9bda to 7a5e57f Compare February 21, 2024 17:54
Copy link
Member

@jzempel jzempel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a migration.md entry for the rename, type extend change, and prop update.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File should be named offsetPagination.stories.mdx (lowercase "o") for consistency with others.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] let's nab this one before merge ☝️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dang. I really thought I pushed this one up. 🤦🏻

GapComponent,
props,
'aria-label',
'Ellipsis indicating non-visible pages'
Copy link
Member

@jzempel jzempel Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth passing a size prop to the gap component so that this default label can be customized with "Ellipsis indicating ${size} non-visible pages"? Certainly non-essential; perhaps nice to have.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that idea. Looks like the calculation is all there already, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the calculation is a bit more involved than I thought. Definitely something to consider in the future though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'm totally fine to defer. But we'll probably need to punt to a future major, because we'd want the labels API to follow suit with a function.

Comment on lines 20 to 25
labels: {
gap: 'Ellipsis indicating non-visible pages',
page: p => `Page ${p}`,
next: 'Next page',
previous: 'Previous page'
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, due to the type mix. But can this be setup so it can be controlled via the story?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could flatten this object & define some argTypes for it, then re-form the labels object in the Story render function?

return css`
min-width: ${height};
max-width: ${math(`${height} * 2`)}; /* [1] */
max-width: ${math(`${height} * 2`)};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we get rid of the expensive math function by making height a number calculation and appending 'px' where necessary?

* @param {string} pageType The type of the page accepting the props
* @param {any} props Default page props to transform
* @param {number} pageNumber The page number
* Provides localized labels to pagination elements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Provides localized labels to pagination elements.
* Provides localized labels to pagination elements

[nit] no period, per content guidelines

@geotrev geotrev requested a review from jzempel February 22, 2024 17:01
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] let's nab this one before merge ☝️

Copy link
Member

@jzempel jzempel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A slight content change suggestion in addition to the file rename request 🙏

Co-authored-by: Jonathan Zempel <jzempel@gmail.com>
@geotrev geotrev merged commit ea9a73b into next Feb 22, 2024
@geotrev geotrev deleted the george/pagination-cleanup branch February 22, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants