migrate DoublePage to Mui 5 (#88)

This commit is contained in:
Aria Moradi
2021-12-04 10:24:16 +03:30
committed by GitHub
parent 24addbdb52
commit 864e1e4fb0

View File

@@ -5,28 +5,16 @@
* 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 from 'react';
import { Box, styled } from '@mui/system';
const useStyles = (settings: IReaderSettings) => makeStyles({
image: {
display: 'block',
const Image = styled('img')({
marginBottom: 0,
width: 'auto',
minHeight: '99vh',
height: 'auto',
maxHeight: '99vh',
objectFit: 'contain',
},
page: {
display: 'flex',
flexDirection: settings.readerType === 'DoubleLTR' ? 'row' : 'row-reverse',
justifyContent: 'center',
margin: '0 auto',
width: 'auto',
height: 'auto',
overflowX: 'scroll',
},
});
interface IProps {
@@ -41,21 +29,28 @@ const DoublePage = React.forwardRef((props: IProps, ref: any) => {
image1src, image2src, index, settings,
} = props;
const classes = useStyles(settings)();
return (
<div ref={ref} className={classes.page}>
<img
className={classes.image}
<Box
ref={ref}
sx={{
display: 'flex',
flexDirection: settings.readerType === 'DoubleLTR' ? 'row' : 'row-reverse',
justifyContent: 'center',
margin: '0 auto',
width: 'auto',
height: 'auto',
overflowX: 'scroll',
}}
>
<Image
src={image1src}
alt={`Page #${index}`}
/>
<img
className={classes.image}
<Image
src={image2src}
alt={`Page #${index + 1}`}
/>
</div>
</Box>
);
});