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
[CardMedia] Add component
property
#8376
Conversation
src/Card/CardMedia.js
Outdated
ComponentProp === 'div' ? { backgroundImage: `url(${image})`, ...style } : style; | ||
const composedClassName = classNames( | ||
{ | ||
[classes.root]: ComponentProp === 'div', |
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.
What if component will be neither div
nor img
? I think in this case it should receive classes.root
styles
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.
Thank you for review!
That's a proper point. I think backgroundImage
should also be added to style
prop in case anything else than img
is specified.
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.
Thank you for contribution ;)
component
prop added.component
property
@AndriusBil Sounds good. The only thing that feels weird is using the |
Thanks for comment! I think it also feels a bit weird using |
@AndriusBil I haven't been thinking about this solution. This one sounds good 👍 . |
I've added While implementing it, I started questioning what is the reason for this component? If we actually wanted to display media (be it image or video or something else) we could use standard html media components. CardMedia only adds |
2aaf25d
to
31cd78d
Compare
@AndriusBil Well done :) |
CardMedia only adds width: 100% style for it. My problem was that svg image was fully responsive but it wasn't working with a specified width. So I changed to maxWidth and it worked fine. |
Fixes: #8233
If
component="img"
specified, then renders img element instead of div.Now it's possible to set srcSet and sizes attributes.
Backwards compatible (in case any users already have custom styling for div e.g. css
image-set
)No documentation / examples as of initial PR.
If this implementation is acceptable, I'll add some documentation.