Skip to content

Commit

Permalink
Update CardMedia.js
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Sep 27, 2017
1 parent c437b80 commit 2aaf25d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Card/CardMedia.js
Expand Up @@ -17,6 +17,8 @@ export const styles = {
},
};

const mediaComponents = ['video', 'audio', 'picture', 'iframe', 'img'];

type DefaultProps = {
classes: Object,
component: ElementType,
Expand Down Expand Up @@ -55,11 +57,11 @@ export type Props = {

function CardMedia(props: DefaultProps & Props) {
const { classes, className, image, style, src, component: ComponentProp, ...other } = props;
warning(image || src, 'Material-UI: Either `image` or `src` prop must be specified');
const mediaComponents = ['video', 'audio', 'picture', 'iframe', 'img'];

const isMediaComponent = mediaComponents.includes(ComponentProp);
const composedStyle = !isMediaComponent ? { backgroundImage: `url(${image})`, ...style } : style;
warning(image || src, 'Material-UI: either `image` or `src` prop must be specified');

const isMediaComponent = mediaComponents.indexOf(ComponentProp) !== -1;
const composedStyle = isMediaComponent ? style : { backgroundImage: `url(${image})`, ...style };
const composedClassName = classNames(
{
[classes.root]: !isMediaComponent,
Expand Down

0 comments on commit 2aaf25d

Please sign in to comment.