-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Fix Avatar CSS issue #18156
[Chip] Fix Avatar CSS issue #18156
Changes from all commits
5131bea
d778802
6eb197c
678fd1d
6e01dee
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 |
---|---|---|
|
@@ -8,7 +8,6 @@ import useForkRef from '../utils/useForkRef'; | |
import unsupportedProp from '../utils/unsupportedProp'; | ||
import capitalize from '../utils/capitalize'; | ||
import ButtonBase from '../ButtonBase'; | ||
import '../Avatar'; // So we don't have any override priority issue. | ||
|
||
export const styles = theme => { | ||
const backgroundColor = | ||
|
@@ -42,6 +41,29 @@ export const styles = theme => { | |
opacity: 0.5, | ||
pointerEvents: 'none', | ||
}, | ||
'& $avatar': { | ||
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. I'm curious whether or not you deem this a breaking change because strictly speaking specificity is increased 😅 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. The outlined variant already increases the specificity to style the avatar. 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. True - but let's say someone was just specifying a single 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. @NMinhNguyen If somebody has overridden the class, he would likely face #16374, as we do. He would already be forced to increase the specificity. |
||
marginLeft: 5, | ||
marginRight: -6, | ||
width: 24, | ||
height: 24, | ||
color: theme.palette.type === 'light' ? theme.palette.grey[700] : theme.palette.grey[300], | ||
fontSize: theme.typography.pxToRem(12), | ||
}, | ||
'& $avatarColorPrimary': { | ||
color: theme.palette.primary.contrastText, | ||
backgroundColor: theme.palette.primary.dark, | ||
}, | ||
'& $avatarColorSecondary': { | ||
color: theme.palette.secondary.contrastText, | ||
backgroundColor: theme.palette.secondary.dark, | ||
}, | ||
'& $avatarSmall': { | ||
marginLeft: 4, | ||
marginRight: -4, | ||
width: 18, | ||
height: 18, | ||
fontSize: theme.typography.pxToRem(10), | ||
}, | ||
}, | ||
/* Styles applied to the root element if `size="small"`. */ | ||
sizeSmall: { | ||
|
@@ -145,32 +167,15 @@ export const styles = theme => { | |
backgroundColor: fade(theme.palette.secondary.main, theme.palette.action.hoverOpacity), | ||
}, | ||
}, | ||
// TODO remove in V5 | ||
/* Styles applied to the `avatar` element. */ | ||
avatar: { | ||
marginLeft: 5, | ||
marginRight: -6, | ||
width: 24, | ||
height: 24, | ||
color: theme.palette.type === 'light' ? theme.palette.grey[700] : theme.palette.grey[300], | ||
fontSize: theme.typography.pxToRem(12), | ||
}, | ||
avatarSmall: { | ||
marginLeft: 4, | ||
marginRight: -4, | ||
width: 18, | ||
height: 18, | ||
fontSize: theme.typography.pxToRem(10), | ||
}, | ||
avatar: {}, | ||
/* Styles applied to the `avatar` element if `size="small"`. */ | ||
avatarSmall: {}, | ||
/* Styles applied to the `avatar` element if `color="primary"`. */ | ||
avatarColorPrimary: { | ||
color: theme.palette.primary.contrastText, | ||
backgroundColor: theme.palette.primary.dark, | ||
}, | ||
avatarColorPrimary: {}, | ||
/* Styles applied to the `avatar` element if `color="secondary"`. */ | ||
avatarColorSecondary: { | ||
color: theme.palette.secondary.contrastText, | ||
backgroundColor: theme.palette.secondary.dark, | ||
}, | ||
avatarColorSecondary: {}, | ||
/* Styles applied to the `icon` element. */ | ||
icon: { | ||
color: theme.palette.type === 'light' ? theme.palette.grey[700] : theme.palette.grey[300], | ||
|
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.
Do you think a "harmless" side-effect such as
Avatar.propTypes = Avatar.propTypes
(or similar, likeAvatar.a = Avatar.a
) might suffice? I'm on holiday rn so I don't have much time to look into this issue myself, sorry.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.
After more reflexion, I think that having to pull out another module to get the correct side effect isn't right. It prevents tree-shaking. Autocomplete users shouldn't bundle the Avatar if they don't use it.
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.
Enjoy your holidays 👍