-
Notifications
You must be signed in to change notification settings - Fork 352
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
feat(Chip): Add the Chip component to PF4 #1076
Conversation
PatternFly-React preview: https://1076-pr-patternfly-react-patternfly.surge.sh |
Pull Request Test Coverage Report for Build 3877
💛 - Coveralls |
PatternFly-React preview: https://1076-pr-patternfly-react-patternfly.surge.sh |
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.
Great implementation! I like how you split the component into multiple small components and kept them as simple as possible.
packages/patternfly-4/react-core/src/components/Chip/examples/SimpleChip.js
Outdated
Show resolved
Hide resolved
packages/patternfly-4/react-core/src/components/Chip/ChipWrapper.js
Outdated
Show resolved
Hide resolved
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.
@boaz1337 Looks like there's some conflicts on this one that need to be resolved.
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.
Looks good jus had a few questions (inline with the code).
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.
Looks good @boaz0 . For Core had separate components for Chip and Chip Group. Will Chip Group be coming separately for React also?
When the text truncates, can we add a tooltip to display the full label?
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.
Looks good overall, but you don't need aria-label="4 more"
on the .pf-m-overflow
example. aria-label
is only needed when an icon is used with no supporting text.
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
}; | ||
|
||
export interface ChipProps extends Omit<HTMLProps<HTMLDivElement>, 'children' > { | ||
children: string; |
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 file should be updated as well. It is missing id and onClick and isOverflowed is no longer a prop.
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 you get rid of the Omit 'children' and remove children from the interface? Also don't need id and onClick I believe since they are included in HTMLProps
}; | ||
|
||
const Chip = ({ variant, onClick, children, id, position, className, ...props }) => { | ||
const idChip = id || getUniqueId() |
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 will not work if there are multiple chips on the page. They will all have the same id. You can wrap it with the GenerateId component to get a unique id.
case ChipVariant.overflow: | ||
return ( | ||
<div className={css(styles.chip, styles.modifiers.overflow, className)} {...props}> | ||
<ChipButton onClick={onClick} aria-label="Expand chip"> |
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-label should be removed here, to match core. It is not needed since the button has text.
<span className={css(styles.chipText)} id={idChip}> | ||
{children} | ||
</span> | ||
<ChipButton onClick={onClick} aria-label="Remove" id={`remove_${idChip}`} aria-labelledby={`remove_${idChip} ${idChip}`}> |
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 localization purposes, all user visible/audible text should be customizable. Maybe we can add an optional prop for the button's aria Label.
}; | ||
|
||
export interface ChipProps extends Omit<HTMLProps<HTMLDivElement>, 'children' > { | ||
children: string; |
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 you get rid of the Omit 'children' and remove children from the interface? Also don't need id and onClick I believe since they are included in HTMLProps
</ChipButton> | ||
</div> | ||
); | ||
return children.length < 16 ? ( |
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.
Curious why 16? Should this be customizable?
@boaz0 I have opened a new PR for this as we need to expedite the process. I was unable to find a way to contact you but perhaps we can meet & pair program if your are in the Raleigh area this week. Thank you for your hard work on this. I have kept all of your commits intact & just cherry picked from your branch. New PR is #1180 |
@ibolton336 no problem. Although, I am in Raleigh this week, I don't think I have the time to join in. Thanks for the invitation, though. 😀 |
What: #976