-
-
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
Changes from 3 commits
4475309
f38bd04
bac0882
ec7b22e
83d2452
3d7a5db
08b802d
190f869
b827001
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -13,7 +13,8 @@ import styled from '../styles/styled'; | |||||
import chipClasses, { getChipUtilityClass } from './chipClasses'; | ||||||
|
||||||
const useUtilityClasses = (ownerState) => { | ||||||
const { classes, disabled, size, color, iconColor, onDelete, clickable, variant } = ownerState; | ||||||
const { classes, disabled, size, color, iconColor, onDelete, clickable, variant, rounded } = | ||||||
ownerState; | ||||||
|
||||||
const slots = { | ||||||
root: [ | ||||||
|
@@ -27,6 +28,7 @@ const useUtilityClasses = (ownerState) => { | |||||
onDelete && 'deletable', | ||||||
onDelete && `deletableColor${capitalize(color)}`, | ||||||
`${variant}${capitalize(color)}`, | ||||||
rounded && 'rounded', | ||||||
], | ||||||
label: ['label', `label${capitalize(size)}`], | ||||||
avatar: ['avatar', `avatar${capitalize(size)}`, `avatarColor${capitalize(color)}`], | ||||||
|
@@ -37,6 +39,7 @@ const useUtilityClasses = (ownerState) => { | |||||
`deleteIconColor${capitalize(color)}`, | ||||||
`deleteIcon${capitalize(variant)}Color${capitalize(color)}`, | ||||||
], | ||||||
rounded: ['rounded', `rounded`], | ||||||
}; | ||||||
|
||||||
return composeClasses(slots, getChipUtilityClass, classes); | ||||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(Will need to destructure |
||||||
styles.root, | ||||||
styles[`size${capitalize(size)}`], | ||||||
styles[`color${capitalize(color)}`], | ||||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
borderRadius: 32 / 4, | ||||||
}), | ||||||
...(ownerState.color !== 'default' && { | ||||||
backgroundColor: (theme.vars || theme).palette[ownerState.color].main, | ||||||
color: (theme.vars || theme).palette[ownerState.color].contrastText, | ||||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just passing by, why do you need a |
||||||
size = 'medium', | ||||||
variant = 'filled', | ||||||
tabIndex, | ||||||
|
@@ -397,6 +405,7 @@ const Chip = React.forwardRef(function Chip(inProps, ref) { | |||||
onDelete: !!onDelete, | ||||||
clickable, | ||||||
variant, | ||||||
rounded, | ||||||
}; | ||||||
|
||||||
const classes = useUtilityClasses(ownerState); | ||||||
|
@@ -549,6 +558,11 @@ Chip.propTypes /* remove-proptypes */ = { | |||||
* @ignore | ||||||
*/ | ||||||
onKeyUp: PropTypes.func, | ||||||
/** | ||||||
* Makes chips rounded instead of circular default | ||||||
* @default true | ||||||
*/ | ||||||
rounded: PropTypes.bool, | ||||||
/** | ||||||
* The size of the component. | ||||||
* @default 'medium' | ||||||
|
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.