Skip to content

Commit 864e1e4

Browse files
authored
migrate DoublePage to Mui 5 (#88)
1 parent 24addbd commit 864e1e4

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

src/components/reader/DoublePage.tsx

+23-28
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,16 @@
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
66
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
77

8-
import makeStyles from '@mui/styles/makeStyles';
98
import React from 'react';
9+
import { Box, styled } from '@mui/system';
1010

11-
const useStyles = (settings: IReaderSettings) => makeStyles({
12-
image: {
13-
display: 'block',
14-
marginBottom: 0,
15-
width: 'auto',
16-
minHeight: '99vh',
17-
height: 'auto',
18-
maxHeight: '99vh',
19-
objectFit: 'contain',
20-
},
21-
page: {
22-
display: 'flex',
23-
flexDirection: settings.readerType === 'DoubleLTR' ? 'row' : 'row-reverse',
24-
justifyContent: 'center',
25-
margin: '0 auto',
26-
width: 'auto',
27-
height: 'auto',
28-
overflowX: 'scroll',
29-
},
11+
const Image = styled('img')({
12+
marginBottom: 0,
13+
width: 'auto',
14+
minHeight: '99vh',
15+
height: 'auto',
16+
maxHeight: '99vh',
17+
objectFit: 'contain',
3018
});
3119

3220
interface IProps {
@@ -41,21 +29,28 @@ const DoublePage = React.forwardRef((props: IProps, ref: any) => {
4129
image1src, image2src, index, settings,
4230
} = props;
4331

44-
const classes = useStyles(settings)();
45-
4632
return (
47-
<div ref={ref} className={classes.page}>
48-
<img
49-
className={classes.image}
33+
<Box
34+
ref={ref}
35+
sx={{
36+
display: 'flex',
37+
flexDirection: settings.readerType === 'DoubleLTR' ? 'row' : 'row-reverse',
38+
justifyContent: 'center',
39+
margin: '0 auto',
40+
width: 'auto',
41+
height: 'auto',
42+
overflowX: 'scroll',
43+
}}
44+
>
45+
<Image
5046
src={image1src}
5147
alt={`Page #${index}`}
5248
/>
53-
<img
54-
className={classes.image}
49+
<Image
5550
src={image2src}
5651
alt={`Page #${index + 1}`}
5752
/>
58-
</div>
53+
</Box>
5954
);
6055
});
6156

0 commit comments

Comments
 (0)