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

[@react-ui] Add initialSelectedPage to Pagination Component #815

Merged

Conversation

KristinaSpasevska
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Aug 23, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 28, 2023 8:00am
4 Ignored Deployments
Name Status Preview Comments Updated (UTC)
alpha-docs ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2023 8:00am
docs-storybook ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2023 8:00am
immutable-records ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2023 8:00am
tools ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2023 8:00am

@@ -65,6 +74,7 @@ export const Controlled: Story = {
currentPage={page}
label={label}
visiblePageLimit={visiblePageLimit}
initialSetPage={initialSetPage}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Do you think initialPage would be more concise and still clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should have been initialSelectedPage , but initialPage is fine too

Copy link
Contributor

Choose a reason for hiding this comment

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

initialSelectedPage is fine with me as well! initialSetPage just felt a bit strange, but I'm ok with either of the other options 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Set to initialSelectedPage

Copy link
Contributor

@eileenmguo eileenmguo left a comment

Choose a reason for hiding this comment

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

Looking at storybook. It doesn't have any selected page if the initialSelectedPage is not valid. Can you update it to set it to the first page if this is the case or implement another solution?

Also unrelated to your changes, but I realized I forgot to wrap the PageNum component in an li. Could you add that in this PR?

const [page, setPage] = React.useState(1);
render: ({ totalPages, label, visiblePageLimit, initialSelectedPage }) => {
const validInitialSelectedPage =
initialSelectedPage && initialSelectedPage <= totalPages;
Copy link
Contributor

Choose a reason for hiding this comment

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

should also be greater than 0

Comment on lines 78 to 85
render: ({ totalPages, label, visiblePageLimit, initialSelectedPage }) => {
const validInitialSelectedPage =
initialSelectedPage &&
initialSelectedPage <= totalPages &&
initialSelectedPage > 0;
const [page, setPage] = React.useState(
validInitialSelectedPage ? initialSelectedPage : 1,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this logic be removed from the story? I think the component should handle it internally

max: 20,
step: 1,
},
description: 'Which page should be selected at start?',
Copy link
Contributor

@eileenmguo eileenmguo Aug 24, 2023

Choose a reason for hiding this comment

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

Suggested change
description: 'Which page should be selected at start?',
description: 'The default selected page before any interaction. If the `currentPage` prop is provided, it will override this value.',

@@ -27,6 +36,7 @@ const meta: Meta<
max: 20,
step: 2,
},
description: 'Total number of pages',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: 'Total number of pages',
description: 'Total number of pages.',

argTypes: {
label: {
control: {
type: 'text',
},
description: 'We use this to give info to screen readers',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: 'We use this to give info to screen readers',
description: 'Text that is passed to the Nav element as an aria-label for accessibility.',

@@ -35,6 +45,16 @@ const meta: Meta<
max: 7,
step: 1,
},
description: 'Number of pages that would be visible',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: 'Number of pages that would be visible',
description: 'Number of pages that are visible and can be directly selected.',

docs: {
description: {
component:
'<i>Note: maximum navigation items is currently limited (not technically enforced).</i><br><br><strong>Label </strong><br> is used to allow screen readers to notify user that there is a pagination here.',
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean by this? <i>Note: maximum navigation items is currently limited (not technically enforced)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think @KristinaSpasevska took that from the navheader, it's not relevant to this PR or the pagination component 😁

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 took that from the NavHeader, but I thought it would be nice to notify the user that the limit we put in the storybook for the total number of pages is only for the usage of the component here (it's not a technical limitation)
Screenshot 2023-08-24 at 16 33 55

Copy link
Contributor

Choose a reason for hiding this comment

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

The label description is duplicated in the props section. I do think that this text overall is more confusing than it is helpful right now. I would suggest just writing a a plain text description for what the component does/is used for

@KristinaSpasevska KristinaSpasevska merged commit e6bd03f into main Aug 29, 2023
3 checks passed
@KristinaSpasevska KristinaSpasevska deleted the feat/react-ui/add-initialSelectedPage-to-pagination branch August 29, 2023 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants