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

feat(Chip): Add the Chip component to PF4 #1076

Closed
wants to merge 1 commit into from
Closed

feat(Chip): Add the Chip component to PF4 #1076

wants to merge 1 commit into from

Conversation

boaz0
Copy link
Member

@boaz0 boaz0 commented Dec 18, 2018

What: #976

@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://1076-pr-patternfly-react-patternfly.surge.sh

@coveralls
Copy link

coveralls commented Dec 18, 2018

Pull Request Test Coverage Report for Build 3877

  • 13 of 13 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 81.278%

Totals Coverage Status
Change from base Build 3866: 0.07%
Covered Lines: 4381
Relevant Lines: 5087

💛 - Coveralls

@patternfly-build
Copy link
Contributor

PatternFly-React preview: https://1076-pr-patternfly-react-patternfly.surge.sh

Copy link
Contributor

@karelhala karelhala left a 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.

@tlabaj tlabaj added the PF4 label Dec 18, 2018
ibolton336
ibolton336 previously approved these changes Dec 20, 2018
dlabaj
dlabaj previously approved these changes Jan 3, 2019
Copy link
Contributor

@dlabaj dlabaj left a 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.

@boaz0 boaz0 dismissed stale reviews from dlabaj and ibolton336 via bb59c4d January 4, 2019 10:13
Copy link
Contributor

@tlabaj tlabaj left a 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).

@tlabaj tlabaj requested review from mcarrano and mcoker January 8, 2019 20:49
Copy link
Member

@mcarrano mcarrano left a 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?

Copy link
Contributor

@mcoker mcoker left a 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.

@boaz0
Copy link
Member Author

boaz0 commented Jan 9, 2019

@tlabaj thanks. I removed ChipText and ChipWrapper as you suggested and used getUniqueId to set a default id.

@mcarrano yes. I will add ChipGroup later. I also did as you suggested: adding tooltip.

@mcoker thanks. I removed aria-label. Let me know if I'm missing anything.

Thank you all.

Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
};

export interface ChipProps extends Omit<HTMLProps<HTMLDivElement>, 'children' > {
children: string;
Copy link
Contributor

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.

Copy link
Collaborator

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()
Copy link
Contributor

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">
Copy link
Contributor

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}`}>
Copy link
Contributor

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;
Copy link
Collaborator

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 ? (
Copy link
Collaborator

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?

@ibolton336
Copy link
Member

ibolton336 commented Jan 14, 2019

@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 ibolton336 closed this Jan 15, 2019
@boaz0
Copy link
Member Author

boaz0 commented Jan 15, 2019

@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. 😀

@boaz0 boaz0 deleted the chips branch January 15, 2019 09:17
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.

10 participants