migrate SpinnerImage to Mui 5 (#97)

* migrate Page to Mui 5

* migrate SpinnerImage to Mui 5

* match the style
This commit is contained in:
Aria Moradi
2021-12-01 03:06:06 +03:30
committed by GitHub
parent c214406546
commit a8444e5101
2 changed files with 17 additions and 30 deletions

View File

@@ -17,9 +17,7 @@ interface IProps {
imgRef?: React.RefObject<HTMLImageElement>
spinnerClassName?: string
spinnerStyle?: SxProps<Theme>
imgClassName?: string
imgStyle?: CSSProperties
onImageLoad?: () => void
@@ -27,7 +25,7 @@ interface IProps {
export default function SpinnerImage(props: IProps) {
const {
src, alt, onImageLoad, imgRef, spinnerClassName, imgClassName, spinnerStyle, imgStyle,
src, alt, onImageLoad, imgRef, spinnerStyle, imgStyle,
} = props;
const [imageSrc, setImagsrc] = useState<string>('');
@@ -53,19 +51,18 @@ export default function SpinnerImage(props: IProps) {
if (imageSrc.length === 0) {
return (
<Box className={spinnerClassName} sx={spinnerStyle}>
<Box sx={spinnerStyle}>
<CircularProgress thickness={5} />
</Box>
);
}
if (imageSrc === 'Not Found') {
return <Box className={spinnerClassName} sx={spinnerStyle} />;
return <Box sx={spinnerStyle} />;
}
return (
<img
className={imgClassName}
style={imgStyle}
ref={imgRef}
src={imageSrc}
@@ -75,8 +72,6 @@ export default function SpinnerImage(props: IProps) {
}
SpinnerImage.defaultProps = {
spinnerClassName: '',
imgClassName: '',
spinnerStyle: {},
imgStyle: {},
onImageLoad: () => {},