-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
stacey-gammon
commented
May 15, 2017
There was a problem hiding this 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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type="basic" | ||
onClick={onPrevious} | ||
disabled={!hasPrevious} | ||
icon={<KuiButtonIcon type="previous" />} |
There was a problem hiding this comment.
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
)?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
ui_framework/components/index.js
Outdated
|
||
export { | ||
KuiPager, | ||
KuiPagerButtons |
There was a problem hiding this comment.
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 }) { |
There was a problem hiding this comment.
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}–{endNumber} of {totalItems}</div> | ||
{ | ||
startNumber === 1 && endNumber === totalItems |
There was a problem hiding this comment.
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" />} |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A period here, too?
f2c9709
to
344a3bb
Compare
@cjcenizal, @weltenwort all changes and questions should be addressed now. Thanks! |
There was a problem hiding this 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" />} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" />} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore this too
@weltenwort any more feedback or is this good to go? Thanks! |
* Introduce react pager component * Rename KuiPagerButtons to KuiPagerButtonGroup * Address code review comments * update snapshots with new aria labels. * fix merge issue
I just found this and it's awesome! I will definitely use it in #12150 |
omg @tsullivan I think I just stepped on your toes -- #12349 -- I didn't realize you were reactifying stuff too. |
@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. |