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

[Chip] adding 'rounded' property to chip component #37576

Closed
wants to merge 9 commits into from

Conversation

cam-cole
Copy link

@cam-cole cam-cole commented Jun 12, 2023

Resolves: #22471

@mui-bot
Copy link

mui-bot commented Jun 12, 2023

Netlify deploy preview

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against b827001

@cam-cole cam-cole changed the title [Chip] adding 'rounded' property to chip component [Chip] adding 'rounded' property to chip component [component: chip] Jun 12, 2023
@cam-cole cam-cole changed the title [Chip] adding 'rounded' property to chip component [component: chip] [Chip] adding 'rounded' property to chip component Jun 12, 2023
@zannager zannager added the component: chip This is the name of the generic UI component, not the React module! label Jun 13, 2023
@zannager zannager requested a review from siriwatknp June 13, 2023 07:29
@siriwatknp
Copy link
Member

@cam-cole Thanks for working on it. Can you link to the issue that this PR will fix?

@cam-cole
Copy link
Author

@siriwatknp No problem! The issue is #22471

@mnajdova mnajdova requested a review from DiegoAndai June 21, 2023 08:52
@mnajdova mnajdova added the package: material-ui Specific to @mui/material label Jun 21, 2023
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

The implementation is not exactly what the issue is about. I would recommend instead adding the size property, for allowing denser chips. All chips are rounded right now. We can also link this issue as "related to" instead of "fixes" as there are multiple concepts described in the issue.

@cam-cole
Copy link
Author

@mnajdova Thanks for the feedback! However, I believe my implementation hits on one of the three pieces within the issue in that it allows users to have the chips be rounded instead of circular by adding the rounded prop. Let me know if you think I am missing something here or you have suggestions.

I also asked within the issue for guidance on what other colors are wanted to be supported for this component but haven't heard anything so far.

Also, do you have any guidance for allowing denser chips in what it's wanted to look like? It already seems that the having the size prop as small makes for a denser chip.

Thank you for any help and guidance, I've enjoyed starting to contribute to MUI!

@DiegoAndai DiegoAndai self-assigned this Jun 22, 2023
@DiegoAndai
Copy link
Member

DiegoAndai commented Jun 22, 2023

Hey @cam-cole, thanks for the contribution! 😊 🎉

Regarding #22471 proposals:

  1. Broaden the supported colors: The current flexibility using the color prop is enough, which allows for seven preset colors as well as colors defined by extending the palette. The sx prop provides even more flexibility.
  2. Provide a mode with more density: The current small size is enough.
  3. Allow changing the shape from circular to rounded: This PR adds support for it.

So to merge this PR we should:

Besides that, I leave a couple of code improvements in separate comments. Also remember to run yarn docs:api to update the API documentation (see contributing guide).

And with that, this PR would close #22471 🚀

@@ -172,6 +176,9 @@ const ChipRoot = styled('div', {
...(ownerState.size === 'small' && {
height: 24,
}),
...(ownerState.rounded === true && {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
...(ownerState.rounded === true && {
...(ownerState.rounded && {

@@ -337,6 +344,7 @@ const Chip = React.forwardRef(function Chip(inProps, ref) {
onDelete,
onKeyDown,
onKeyUp,
rounded,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
rounded,
rounded = false,

Copy link
Contributor

Choose a reason for hiding this comment

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

just passing by, why do you need a false default value? (I think you don't)

@@ -72,6 +72,11 @@ export interface ChipTypeMap<P = {}, D extends React.ElementType = 'div'> {
* @default 'medium'
*/
size?: OverridableStringUnion<'small' | 'medium', ChipPropsSizeOverrides>;
/**
* If 'true' the component will be rounded instead of circular
* @default true
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @default true
* @default false

@@ -63,6 +66,7 @@ const ChipRoot = styled('div', {
[`& .${chipClasses.deleteIcon}`]:
styles[`deleteIcon${capitalize(variant)}Color${capitalize(color)}`],
},
{ [`& .${chipClasses.rounded}`]: styles.rounded },
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{ [`& .${chipClasses.rounded}`]: styles.rounded },
rounded && styles.rounded

(Will need to destructure rounded from ownerState in line 53 above)

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 30, 2023
@DiegoAndai
Copy link
Member

Hey @cam-cole! Will you be able to continue working on this PR? Otherwise, I will try to finish it.

We'll need to make some changes to accommodate the migration to Material You better.

@cam-cole
Copy link
Author

Hey @DiegoAndai, I just pushed a new commit addressing the comments you made. I believe I have everything complete!

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 16, 2023
@DiegoAndai
Copy link
Member

Hey @cam-cole, thanks!

We've been discussing this change with the MUI core team and decided that we shouldn't add the rounded property for two reasons:

  • We're implementing Material You for Material UI v6, and this prop would make the migration harder as Material You has rounded chips by default. We would introduce a prop that would probably be removed or deprecated soon.
  • It's a prop to control a single CSS property. It can be replaced by using the sx prop (e.g., sx={{ borderRadius: '8px' }}) or a theme style override.

We could instead add an example of how to achieve what was stated in #22471, for example: https://codesandbox.io/s/22471-docs-example-xjwfst

That said, thanks for working on this, and if you're interested in adding the proposed example to the docs I would be more than happy to review that PR.

@cam-cole cam-cole closed this Oct 17, 2023
@cam-cole cam-cole deleted the support-simple-badges branch October 17, 2023 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: chip This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support simple badges
8 participants