-
-
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
[Avatar] Fix img slot types and add missing slots #45483
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -11,11 +11,17 @@ | |
}, | ||
"sizes": { "type": { "name": "string" } }, | ||
"slotProps": { | ||
"type": { "name": "shape", "description": "{ img?: func<br>| object }" }, | ||
"type": { | ||
"name": "shape", | ||
"description": "{ fallback?: func<br>| object, img?: func<br>| object, root?: func<br>| object }" | ||
}, | ||
"default": "{}" | ||
}, | ||
"slots": { | ||
"type": { "name": "shape", "description": "{ img?: elementType }" }, | ||
"type": { | ||
"name": "shape", | ||
"description": "{ fallback?: elementType, img?: elementType, root?: elementType }" | ||
}, | ||
"default": "{}" | ||
}, | ||
"src": { "type": { "name": "string" } }, | ||
|
@@ -41,11 +47,23 @@ | |
"import { Avatar } from '@mui/material';" | ||
], | ||
"slots": [ | ||
{ | ||
"name": "root", | ||
"description": "The component that renders the root slot.", | ||
"default": "'div'", | ||
"class": "MuiAvatar-root" | ||
}, | ||
{ | ||
"name": "img", | ||
"description": "The component that renders the transition.\n[Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.", | ||
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. This is wrong. |
||
"default": "Collapse", | ||
"description": "The component that renders the img slot.", | ||
"default": "'img'", | ||
"class": "MuiAvatar-img" | ||
}, | ||
{ | ||
"name": "fallback", | ||
"description": "The component that renders the fallback slot.", | ||
"default": "Person icon", | ||
"class": "MuiAvatar-fallback" | ||
} | ||
], | ||
"classes": [ | ||
|
@@ -61,18 +79,6 @@ | |
"description": "Styles applied to the root element if not `src` or `srcSet`.", | ||
"isGlobal": false | ||
}, | ||
{ | ||
"key": "fallback", | ||
"className": "MuiAvatar-fallback", | ||
"description": "Styles applied to the fallback icon", | ||
"isGlobal": false | ||
}, | ||
{ | ||
"key": "root", | ||
"className": "MuiAvatar-root", | ||
"description": "Styles applied to the root element.", | ||
"isGlobal": false | ||
}, | ||
{ | ||
"key": "rounded", | ||
"className": "MuiAvatar-rounded", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,14 @@ describe('<Avatar />', () => { | |
testDeepOverrides: { slotName: 'fallback', slotClassName: classes.fallback }, | ||
testVariantProps: { variant: 'foo' }, | ||
testStateOverrides: { prop: 'variant', value: 'rounded', styleKey: 'rounded' }, | ||
slots: { | ||
root: { | ||
expectedClassName: classes.root, | ||
}, | ||
fallback: { | ||
expectedClassName: classes.fallback, | ||
}, | ||
}, | ||
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. Cannot test the |
||
skip: ['componentsProp'], | ||
})); | ||
|
||
|
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.
unnecessary assertion
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.
In this case, it's still required because the
slotProps.img
has a fixed structure that's different fromImageProps
.If you exclude the line, TS throws an error.