Skip to content

migrate Manga to Mui 5 #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 15 additions & 34 deletions src/screens/Manga.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

import React, { useEffect, useState, useContext } from 'react';
import { Theme } from '@mui/material/styles';
import makeStyles from '@mui/styles/makeStyles';
import { Box, styled } from '@mui/system';
import { Link, useParams } from 'react-router-dom';
import { Virtuoso } from 'react-virtuoso';
import ChapterCard from 'components/ChapterCard';
Expand All @@ -19,31 +18,16 @@ import makeToast from 'components/util/Toast';
import { Fab } from '@mui/material';
import PlayArrow from '@mui/icons-material/PlayArrow';

const useStyles = makeStyles((theme: Theme) => ({
root: {
[theme.breakpoints.up('md')]: {
display: 'flex',
},
overflow: 'hidden',
const StyledVirtuoso = styled(Virtuoso)((({ theme }) => ({
listStyle: 'none',
padding: 0,
minHeight: '200px',
[theme.breakpoints.up('md')]: {
width: '50vw',
height: 'calc(100vh - 64px)',
margin: 0,
},

chapters: {
listStyle: 'none',
padding: 0,
minHeight: '200px',
[theme.breakpoints.up('md')]: {
width: '50vw',
height: 'calc(100vh - 64px)',
margin: 0,
},
},

loading: {
margin: '10px 0',
display: 'flex',
justifyContent: 'center',
},
}));
})));

const baseWebsocketUrl = JSON.parse(window.localStorage.getItem('serverBaseURL')!).replace('http', 'ws');
const initialQueue = {
Expand All @@ -52,8 +36,6 @@ const initialQueue = {
} as IQueue;

export default function Manga() {
const classes = useStyles();

const { setTitle } = useContext(NavbarContext);
useEffect(() => { setTitle('Manga'); }, []); // delegate setting topbar action to MangaDetails

Expand Down Expand Up @@ -153,7 +135,7 @@ export default function Manga() {
));

return (
<div className={classes.root}>
<Box sx={{ display: { md: 'flex' }, overflow: 'hidden' }}>
<LoadingPlaceholder
shouldRender={manga !== undefined}
component={MangaDetails}
Expand All @@ -163,12 +145,11 @@ export default function Manga() {
<LoadingPlaceholder
shouldRender={chapters.length > 0 || noChaptersFound}
>
<Virtuoso
<StyledVirtuoso
style={{ // override Virtuoso default values and set them with class
height: 'undefined',
overflowY: window.innerWidth < 960 ? 'visible' : 'auto',
overflowY: window.innerWidth < 900 ? 'visible' : 'auto',
}}
className={classes.chapters}
totalCount={chapters.length}
itemContent={(index:number) => (
<ChapterCard
Expand All @@ -177,11 +158,11 @@ export default function Manga() {
triggerChaptersUpdate={triggerChaptersUpdate}
/>
)}
useWindowScroll={window.innerWidth < 960}
useWindowScroll={window.innerWidth < 900}
overscan={window.innerHeight * 0.5}
/>
</LoadingPlaceholder>
<ResumeFab />
</div>
</Box>
);
}