From a8444e5101a4b63fdb78c21b5b8e6100b9a6be57 Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Wed, 1 Dec 2021 03:06:06 +0330 Subject: [PATCH] migrate SpinnerImage to Mui 5 (#97) * migrate Page to Mui 5 * migrate SpinnerImage to Mui 5 * match the style --- src/components/reader/Page.tsx | 36 +++++++++++----------------- src/components/util/SpinnerImage.tsx | 11 +++------ 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/components/reader/Page.tsx b/src/components/reader/Page.tsx index df57b976..2f1f4224 100644 --- a/src/components/reader/Page.tsx +++ b/src/components/reader/Page.tsx @@ -5,10 +5,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import makeStyles from '@mui/styles/makeStyles'; import React, { useEffect, useRef } from 'react'; import SpinnerImage from 'components/util/SpinnerImage'; import useLocalStorage from 'util/useLocalStorage'; +import Box from '@mui/system/Box'; function imageStyle(settings: IReaderSettings): any { const [dimensions, setDimensions] = React.useState({ @@ -53,22 +53,6 @@ function imageStyle(settings: IReaderSettings): any { }; } -const useStyles = (settings: IReaderSettings) => makeStyles({ - loading: { - margin: '100px auto', - height: '100vh', - width: '100vw', - }, - loadingImage: { - height: '100vh', - width: '70vw', - padding: '50px calc(50% - 20px)', - backgroundColor: '#525252', - marginBottom: 10, - }, - image: imageStyle(settings), -}); - interface IProps { src: string index: number @@ -84,7 +68,6 @@ const Page = React.forwardRef((props: IProps, ref: any) => { const [useCache] = useLocalStorage('useCache', true); - const classes = useStyles(settings)(); const imgRef = useRef(null); const handleVerticalScroll = () => { @@ -120,17 +103,26 @@ const Page = React.forwardRef((props: IProps, ref: any) => { } }, [handleVerticalScroll]); + const imgStyle = imageStyle(settings); + return ( -
+ -
+ ); }); diff --git a/src/components/util/SpinnerImage.tsx b/src/components/util/SpinnerImage.tsx index 91f64b9d..620a823c 100644 --- a/src/components/util/SpinnerImage.tsx +++ b/src/components/util/SpinnerImage.tsx @@ -17,9 +17,7 @@ interface IProps { imgRef?: React.RefObject - spinnerClassName?: string spinnerStyle?: SxProps - 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(''); @@ -53,19 +51,18 @@ export default function SpinnerImage(props: IProps) { if (imageSrc.length === 0) { return ( - + ); } if (imageSrc === 'Not Found') { - return ; + return ; } return ( {},