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

fix(Chip): Added prop to render a badge in the chip after the text #9493

Merged
merged 1 commit into from
Aug 15, 2023

Conversation

tlabaj
Copy link
Contributor

@tlabaj tlabaj commented Aug 14, 2023

What: Closes #9483

@patternfly-build
Copy link
Contributor

patternfly-build commented Aug 14, 2023

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.

LGTM! I left a thought about the prop name, but that's more consideration for a long term approach. I did talk to @lboehling and the current plan is still to deprecate the chip in favor of the label as part of the penta release.

@@ -8,6 +8,8 @@ import { GenerateId } from '../../helpers/GenerateId/GenerateId';
import { getOUIAProps, OUIAProps, getDefaultOUIAId } from '../../helpers';

export interface ChipProps extends React.HTMLProps<HTMLDivElement>, OUIAProps {
/** Badge to add to the chip. The badge will be rendered after the chip text. */
badge?: React.ReactNode;
Copy link
Contributor

Choose a reason for hiding this comment

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

This LGTM, though I wonder about the prop name. Just a thought, but if this were the label, I'm thinking we may add a div.pf-v5-c-label__count element inside the label as a container for the count, and the badge (or whatever is used to convey the count) goes in there. That would let us us place/position a count in a label as separate from some other use of a badge in the label. So I would probably advocate for this being called count or something not necessarily tied to the component name, but for the short term in the chip, I think this is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mcoker Are you proposing that they pass a number rather than badge and then we render the badge internally?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it could go a couple of ways. This is also assuming that spot in the chip/label is for a count specifically. It seems like it is, but with a more official implementation in the label, maybe it's worth considering. I think that would also need design input from @andrew-ronaldson @lboehling

  • Use count as the prop, but allow the value to be anything - users could pass a badge or whatever, maybe just text (like (n), so it would read "chip text (9)")
  • If we/design wants control of the count to render in a specific way (eg, always use a badge), we could have the count prop only accept an integer and we manage the badge internally like you mentioned, and that will 1) enforce consistency and 2) allow us to maybe use some other component later if the presentation changes, without breaking the component/prop API.
    • One downside to that is we would probably need to create countOptions or something to manage the props available to pass to the badge (like the button does)

If that spot isn't strictly for a count, we could create a more generic prop and open up that area of the chip/label to allow users to put whatever they want there. It could be a badge for a count, some sort of icon, or whatever - the parent layout will create space between those items. If we went that route, I think we would create some sort of new container for all of that stuff to go in. But here's what I'm referring to using the existing layout:

Screenshot 2023-08-15 at 1 21 07 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

If we will eventually replace Badge with Label then I agree with going for a bit more of a generic or purpose-driven prop name, unless that switch will be more of a v6 thing so we could do that in a breaking change. If that's the case I don't think the prop name is a blocker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kmcfaul Chip will be deprecated and all chip functionality will be available in the Label

@gitdallas gitdallas merged commit ee6d853 into patternfly:main Aug 15, 2023
nicolethoen pushed a commit to Kells512/patternfly-react that referenced this pull request Sep 1, 2023
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.

Bug - Badge no longer has spacing between chip text in chip
6 participants