migrate Manga to Mui 5 (#99)
* migrate Manga to Mui 5 * completetly migrate to new system
This commit is contained in:
@@ -6,8 +6,7 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
import React, { useEffect, useState, useContext } from 'react';
|
import React, { useEffect, useState, useContext } from 'react';
|
||||||
import { Theme } from '@mui/material/styles';
|
import { Box, styled } from '@mui/system';
|
||||||
import makeStyles from '@mui/styles/makeStyles';
|
|
||||||
import { Link, useParams } from 'react-router-dom';
|
import { Link, useParams } from 'react-router-dom';
|
||||||
import { Virtuoso } from 'react-virtuoso';
|
import { Virtuoso } from 'react-virtuoso';
|
||||||
import ChapterCard from 'components/ChapterCard';
|
import ChapterCard from 'components/ChapterCard';
|
||||||
@@ -19,15 +18,7 @@ import makeToast from 'components/util/Toast';
|
|||||||
import { Fab } from '@mui/material';
|
import { Fab } from '@mui/material';
|
||||||
import PlayArrow from '@mui/icons-material/PlayArrow';
|
import PlayArrow from '@mui/icons-material/PlayArrow';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) => ({
|
const StyledVirtuoso = styled(Virtuoso)((({ theme }) => ({
|
||||||
root: {
|
|
||||||
[theme.breakpoints.up('md')]: {
|
|
||||||
display: 'flex',
|
|
||||||
},
|
|
||||||
overflow: 'hidden',
|
|
||||||
},
|
|
||||||
|
|
||||||
chapters: {
|
|
||||||
listStyle: 'none',
|
listStyle: 'none',
|
||||||
padding: 0,
|
padding: 0,
|
||||||
minHeight: '200px',
|
minHeight: '200px',
|
||||||
@@ -36,14 +27,7 @@ const useStyles = makeStyles((theme: Theme) => ({
|
|||||||
height: 'calc(100vh - 64px)',
|
height: 'calc(100vh - 64px)',
|
||||||
margin: 0,
|
margin: 0,
|
||||||
},
|
},
|
||||||
},
|
})));
|
||||||
|
|
||||||
loading: {
|
|
||||||
margin: '10px 0',
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const baseWebsocketUrl = JSON.parse(window.localStorage.getItem('serverBaseURL')!).replace('http', 'ws');
|
const baseWebsocketUrl = JSON.parse(window.localStorage.getItem('serverBaseURL')!).replace('http', 'ws');
|
||||||
const initialQueue = {
|
const initialQueue = {
|
||||||
@@ -52,8 +36,6 @@ const initialQueue = {
|
|||||||
} as IQueue;
|
} as IQueue;
|
||||||
|
|
||||||
export default function Manga() {
|
export default function Manga() {
|
||||||
const classes = useStyles();
|
|
||||||
|
|
||||||
const { setTitle } = useContext(NavbarContext);
|
const { setTitle } = useContext(NavbarContext);
|
||||||
useEffect(() => { setTitle('Manga'); }, []); // delegate setting topbar action to MangaDetails
|
useEffect(() => { setTitle('Manga'); }, []); // delegate setting topbar action to MangaDetails
|
||||||
|
|
||||||
@@ -153,7 +135,7 @@ export default function Manga() {
|
|||||||
));
|
));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<Box sx={{ display: { md: 'flex' }, overflow: 'hidden' }}>
|
||||||
<LoadingPlaceholder
|
<LoadingPlaceholder
|
||||||
shouldRender={manga !== undefined}
|
shouldRender={manga !== undefined}
|
||||||
component={MangaDetails}
|
component={MangaDetails}
|
||||||
@@ -163,12 +145,11 @@ export default function Manga() {
|
|||||||
<LoadingPlaceholder
|
<LoadingPlaceholder
|
||||||
shouldRender={chapters.length > 0 || noChaptersFound}
|
shouldRender={chapters.length > 0 || noChaptersFound}
|
||||||
>
|
>
|
||||||
<Virtuoso
|
<StyledVirtuoso
|
||||||
style={{ // override Virtuoso default values and set them with class
|
style={{ // override Virtuoso default values and set them with class
|
||||||
height: 'undefined',
|
height: 'undefined',
|
||||||
overflowY: window.innerWidth < 960 ? 'visible' : 'auto',
|
overflowY: window.innerWidth < 900 ? 'visible' : 'auto',
|
||||||
}}
|
}}
|
||||||
className={classes.chapters}
|
|
||||||
totalCount={chapters.length}
|
totalCount={chapters.length}
|
||||||
itemContent={(index:number) => (
|
itemContent={(index:number) => (
|
||||||
<ChapterCard
|
<ChapterCard
|
||||||
@@ -177,11 +158,11 @@ export default function Manga() {
|
|||||||
triggerChaptersUpdate={triggerChaptersUpdate}
|
triggerChaptersUpdate={triggerChaptersUpdate}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
useWindowScroll={window.innerWidth < 960}
|
useWindowScroll={window.innerWidth < 900}
|
||||||
overscan={window.innerHeight * 0.5}
|
overscan={window.innerHeight * 0.5}
|
||||||
/>
|
/>
|
||||||
</LoadingPlaceholder>
|
</LoadingPlaceholder>
|
||||||
<ResumeFab />
|
<ResumeFab />
|
||||||
</div>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user