-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Conversation
Netlify deploy previewBundle size reportDetails of bundle changes (Toolpad) |
@cam-cole Thanks for working on it. Can you link to the issue that this PR will fix? |
@siriwatknp No problem! The issue is #22471 |
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.
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.
@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! |
Hey @cam-cole, thanks for the contribution! 😊 🎉 Regarding #22471 proposals:
So to merge this PR we should:
Besides that, I leave a couple of code improvements in separate comments. Also remember to run And with that, this PR would close #22471 🚀 |
@@ -172,6 +176,9 @@ const ChipRoot = styled('div', { | |||
...(ownerState.size === 'small' && { | |||
height: 24, | |||
}), | |||
...(ownerState.rounded === true && { |
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.
...(ownerState.rounded === true && { | |
...(ownerState.rounded && { |
@@ -337,6 +344,7 @@ const Chip = React.forwardRef(function Chip(inProps, ref) { | |||
onDelete, | |||
onKeyDown, | |||
onKeyUp, | |||
rounded, |
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.
rounded, | |
rounded = false, |
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.
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 |
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.
* @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 }, |
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.
{ [`& .${chipClasses.rounded}`]: styles.rounded }, | |
rounded && styles.rounded |
(Will need to destructure rounded
from ownerState
in line 53
above)
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. |
…xtension or sx prop
Hey @DiegoAndai, I just pushed a new commit addressing the comments you made. I believe I have everything complete! |
Signed-off-by: Cameron Cole <[email protected]>
Hey @cam-cole, thanks! We've been discussing this change with the MUI core team and decided that we shouldn't add the
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. |
Resolves: #22471