@@ -4,10 +4,11 @@ import PropTypes from 'prop-types';
4
4
import clsx from 'clsx' ;
5
5
import chainPropTypes from '@mui/utils/chainPropTypes' ;
6
6
import composeClasses from '@mui/utils/composeClasses' ;
7
- import useThemeProps from '../styles/useThemeProps' ;
8
- import styled from '../styles/styled' ;
7
+ import { styled , createUseThemeProps } from '../zero-styled' ;
9
8
import { getCardMediaUtilityClass } from './cardMediaClasses' ;
10
9
10
+ const useThemeProps = createUseThemeProps ( 'MuiCardMedia' ) ;
11
+
11
12
const useUtilityClasses = ( ownerState ) => {
12
13
const { classes, isMediaComponent, isImageComponent } = ownerState ;
13
14
@@ -27,19 +28,27 @@ const CardMediaRoot = styled('div', {
27
28
28
29
return [ styles . root , isMediaComponent && styles . media , isImageComponent && styles . img ] ;
29
30
} ,
30
- } ) ( ( { ownerState } ) => ( {
31
+ } ) ( {
31
32
display : 'block' ,
32
33
backgroundSize : 'cover' ,
33
34
backgroundRepeat : 'no-repeat' ,
34
35
backgroundPosition : 'center' ,
35
- ...( ownerState . isMediaComponent && {
36
- width : '100%' ,
37
- } ) ,
38
- ...( ownerState . isImageComponent && {
39
- // ⚠️ object-fit is not supported by IE11.
40
- objectFit : 'cover' ,
41
- } ) ,
42
- } ) ) ;
36
+ variants : [
37
+ {
38
+ props : { isMediaComponent : true } ,
39
+ style : {
40
+ width : '100%' ,
41
+ } ,
42
+ } ,
43
+ {
44
+ props : { isImageComponent : true } ,
45
+ style : {
46
+ // ⚠️ object-fit is not supported by IE11.
47
+ objectFit : 'cover' ,
48
+ } ,
49
+ } ,
50
+ ] ,
51
+ } ) ;
43
52
44
53
const MEDIA_COMPONENTS = [ 'video' , 'audio' , 'picture' , 'iframe' , 'img' ] ;
45
54
const IMAGE_COMPONENTS = [ 'picture' , 'img' ] ;
0 commit comments