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

Introduce react pager component #11802

Merged
merged 5 commits into from
May 30, 2017

Conversation

stacey-gammon
Copy link
Contributor

screen shot 2017-05-15 at 3 20 34 pm

@stacey-gammon stacey-gammon added the Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. label May 15, 2017
Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

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

Feels good to read such a nice and clean set of React components! 😄 I left a few small questions below.

}

KuiPager.propTypes = {
startNumber: React.PropTypes.number,
Copy link
Member

Choose a reason for hiding this comment

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

Should those numbers be required as well?

endNumber,
totalItems,
hasPreviousPage,
hasNextPage,
Copy link
Member

Choose a reason for hiding this comment

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

Is there a use case in which hasPreviousPage and hasNextPage should not be derived from startNumber, endNumber and totalItems? If not, they could be calculated in here as startNumber > 1 and endNumber < totalItems respectively.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That might not actually always be true. For instance, the add panel pager:
screen shot 2017-05-16 at 2 32 34 pm

endNumber < totalItems but hasNext is false. likewise I could potentially see someone wanting to loop back around to the end if they kept hitting previous.

type="basic"
onClick={onPrevious}
disabled={!hasPrevious}
icon={<KuiButtonIcon type="previous" />}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to specify an aria-label for buttons that only have an icon (which is aria-hidden)?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking the same thing. This button should have aria-label="Show previous page" and the other button should have aria-label-"Show next page".

@@ -160,6 +163,9 @@ const components = [{
component: ModalExample,
hasReact: true,
}, {
name: 'Pager',
component: PagerExample,
Copy link
Member

Choose a reason for hiding this comment

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

hasReact: true, would be justified here

Copy link
Contributor

Choose a reason for hiding this comment

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

@stacey-gammon I just added this feature; with hasReact: true, a little React logo will show up next to the navigation item for this example.

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

This is FANTASTIC! I love how our React components keep growing. I just had a couple small suggestions.


export {
KuiPager,
KuiPagerButtons
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we rename this KuiPagerButtonGroup, to create an analogy with the ButtonGroup component?

hasNextPage,
onNextPage,
onPreviousPage,
...rest }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I hate to nitpick syntax, but can we indent the closing syntax onto the next line, and add a dangling comma here?

  ...rest,
}) {

It makes the parameter list feel more enclosed to me, so I can identify it and differentiate it from the body of the function definition more easily. The dangling comma also adheres to AirBnB's style.

<div className={classes} { ...rest }>
<div className="kuiPagerText">{startNumber}&ndash;{endNumber} of {totalItems}</div>
{
startNumber === 1 && endNumber === totalItems
Copy link
Contributor

Choose a reason for hiding this comment

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

For anyone not quite sure about the order of operations when it comes to evaluating ternaries, how about wrapping this condition in parens?

(startNumber === 1 && endNumber === totalItems)

type="basic"
onClick={onPrevious}
disabled={!hasPrevious}
icon={<KuiButtonIcon type="previous" />}
Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking the same thing. This button should have aria-label="Show previous page" and the other button should have aria-label-"Show next page".

@@ -160,6 +163,9 @@ const components = [{
component: ModalExample,
hasReact: true,
}, {
name: 'Pager',
component: PagerExample,
Copy link
Contributor

Choose a reason for hiding this comment

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

@stacey-gammon I just added this feature; with hasReact: true, a little React logo will show up next to the navigation item for this example.

}]}
>
<GuideText>
Use the Pager in a tool bar
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a period at the end of this sentence?

}]}
>
<GuideText>
Use the Pager Buttons to navigate through a set of items
Copy link
Contributor

Choose a reason for hiding this comment

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

A period here, too?

@stacey-gammon
Copy link
Contributor Author

@cjcenizal, @weltenwort all changes and questions should be addressed now. Thanks!

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

One small thing I missed originally, then LGTM! 🎺

type="basic"
onClick={onPrevious}
disabled={!hasPrevious}
icon={<KuiButtonIcon type="previous" />}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add aria-hidden="true" here? This will prevent screen readers from trying to read the Font Awesome icon, since it's technically text, just using an icon font. If/when we switch to SVG icons this won't matter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually never mind, the React component does this automatically. Sweeeet.

type="basic"
onClick={onNext}
disabled={!hasNext}
icon={<KuiButtonIcon type="next" />}
Copy link
Contributor

Choose a reason for hiding this comment

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

aria-hidden-"true" here too

Copy link
Contributor

Choose a reason for hiding this comment

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

Ignore this too

@stacey-gammon
Copy link
Contributor Author

@weltenwort any more feedback or is this good to go? Thanks!

@stacey-gammon stacey-gammon merged commit 7b1ad58 into elastic:master May 30, 2017
stacey-gammon added a commit to stacey-gammon/kibana that referenced this pull request May 30, 2017
* Introduce react pager component

* Rename KuiPagerButtons to KuiPagerButtonGroup

* Address code review comments

* update snapshots with new aria labels.

* fix merge issue
stacey-gammon added a commit that referenced this pull request May 30, 2017
* Introduce react pager component

* Rename KuiPagerButtons to KuiPagerButtonGroup

* Address code review comments

* update snapshots with new aria labels.

* fix merge issue
@tsullivan
Copy link
Member

I just found this and it's awesome! I will definitely use it in #12150

@stacey-gammon
Copy link
Contributor Author

omg @tsullivan I think I just stepped on your toes -- #12349 -- I didn't realize you were reactifying stuff too.

@tsullivan
Copy link
Member

@stacey-gammon no worries! "Reactifying stuff" is an overstatement for what I've been doing. I think we should sync up though and share some ideas.

@stacey-gammon stacey-gammon deleted the pager-in-react branch October 24, 2017 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. v5.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants