add placeholder prop, add min width and height props
This commit is contained in:
1 parent
3eaf68aa5b
commit
b23ec35260
1 file changed
+15
@@ -11,9 +11,12 @@ const Image = ({
|
|||||||
alt,
|
alt,
|
||||||
width = "auto",
|
width = "auto",
|
||||||
height = "auto",
|
height = "auto",
|
||||||
|
minWidth = "auto",
|
||||||
|
minHeight = "auto",
|
||||||
maxWidth = "auto",
|
maxWidth = "auto",
|
||||||
maxHeight = "auto",
|
maxHeight = "auto",
|
||||||
base64,
|
base64,
|
||||||
|
placeholder,
|
||||||
sx,
|
sx,
|
||||||
}) => {
|
}) => {
|
||||||
if (shouldRender === false) {
|
if (shouldRender === false) {
|
||||||
@@ -28,11 +31,21 @@ const Image = ({
|
|||||||
src = `data:image/png;base64,${base64}`;
|
src = `data:image/png;base64,${base64}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
typeof src === "undefined" &&
|
||||||
|
typeof base64 === "undefined" &&
|
||||||
|
typeof placeholder !== "undefined"
|
||||||
|
) {
|
||||||
|
src = placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
component="img"
|
component="img"
|
||||||
src={src}
|
src={src}
|
||||||
alt={alt}
|
alt={alt}
|
||||||
|
minWidth={minWidth}
|
||||||
|
minHeight={minHeight}
|
||||||
maxWidth={maxWidth}
|
maxWidth={maxWidth}
|
||||||
maxHeight={maxHeight}
|
maxHeight={maxHeight}
|
||||||
width={width}
|
width={width}
|
||||||
@@ -48,6 +61,8 @@ Image.propTypes = {
|
|||||||
alt: PropTypes.string.isRequired,
|
alt: PropTypes.string.isRequired,
|
||||||
width: PropTypes.string,
|
width: PropTypes.string,
|
||||||
height: PropTypes.string,
|
height: PropTypes.string,
|
||||||
|
minWidth: PropTypes.string,
|
||||||
|
minHeight: PropTypes.string,
|
||||||
maxWidth: PropTypes.string,
|
maxWidth: PropTypes.string,
|
||||||
maxHeight: PropTypes.string,
|
maxHeight: PropTypes.string,
|
||||||
base64: PropTypes.string,
|
base64: PropTypes.string,
|
||||||
|
|||||||
Reference in new issue
Block a user