migrate some components to Mui5 new styling system (#72)

* - Changed the value in Manga from 960 to 900( md breakpooint)
- The CicularLoader in About  and Reader screens is now centered to the whole screen
- Changed relative imports in About screen to absolute imports
- removed changed styles from Browse Screen, PageNumber

* Migrated Source Card, Extension Card and LoadingPlaceHolder to MUI system

* Migrated CategorySelect and LandSelect to using the sx prop

* migrated ReaderNavbar to mui 5

* - Removed Unused Styles from Page
- Migrated DoublePage, doublePagedPager, PagedPager, Vertical Pager and Horizontal Pager.

* Replaced style prop with sx prop

* removed useStyles completely from the project except for the Manga Screen

* added a comment

* Fixed the Source Card Buttons padding

* Removed the trailing backspace

Co-authored-by: Sascha Hahne <ntbm@users.noreply.github.com>

Co-authored-by: Sascha Hahne <ntbm@users.noreply.github.com>
This commit is contained in:
abhijeetChawla
2021-11-14 15:51:08 +05:30
committed by GitHub
parent 93c4ce3450
commit 72ef61e286
28 changed files with 341 additions and 501 deletions

View File

@@ -12,7 +12,7 @@ import {
Redirect, Redirect,
} from 'react-router-dom'; } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params'; import { QueryParamProvider } from 'use-query-params';
import { Container, useMediaQuery } from '@mui/material'; import { Container } from '@mui/material';
import CssBaseline from '@mui/material/CssBaseline'; import CssBaseline from '@mui/material/CssBaseline';
import { import {
createTheme, ThemeProvider, Theme, StyledEngineProvider, createTheme, ThemeProvider, Theme, StyledEngineProvider,
@@ -90,8 +90,6 @@ export default function App() {
}), }),
[darkTheme], [darkTheme],
); );
// this can only be used after the theme object is created
const isMobileWidth = useMediaQuery(theme.breakpoints.down('sm'));
return ( return (
<Router> <Router>
@@ -105,10 +103,10 @@ export default function App() {
id="appMainContainer" id="appMainContainer"
maxWidth={false} maxWidth={false}
disableGutters disableGutters
style={{ sx={{
marginTop: theme.spacing(8), mt: 8,
marginLeft: isMobileWidth ? '' : theme.spacing(8), ml: { sm: 8 },
marginBottom: isMobileWidth ? theme.spacing(8) : '', mb: { xs: 8, sm: 4 },
width: 'auto', width: 'auto',
overflow: 'auto', overflow: 'auto',
}} }}

View File

@@ -18,6 +18,7 @@ import MenuItem from '@mui/material/MenuItem';
import BookmarkIcon from '@mui/icons-material/Bookmark'; import BookmarkIcon from '@mui/icons-material/Bookmark';
import client from 'util/client'; import client from 'util/client';
import { Box } from '@mui/system';
interface IProps{ interface IProps{
chapter: IChapter chapter: IChapter
@@ -102,7 +103,7 @@ export default function ChapterCard(props: IProps) {
padding: 2, padding: 2,
}} }}
> >
<div style={{ display: 'flex' }}> <Box sx={{ display: 'flex' }}>
<div style={{ display: 'flex', flexDirection: 'column' }}> <div style={{ display: 'flex', flexDirection: 'column' }}>
<Typography variant="h5" component="h2"> <Typography variant="h5" component="h2">
<span style={{ color: theme.palette.primary.dark }}> <span style={{ color: theme.palette.primary.dark }}>
@@ -117,7 +118,7 @@ export default function ChapterCard(props: IProps) {
{downloadStatusString} {downloadStatusString}
</Typography> </Typography>
</div> </div>
</div> </Box>
<IconButton aria-label="more" onClick={handleClick} size="large"> <IconButton aria-label="more" onClick={handleClick} size="large">
<MoreVertIcon /> <MoreVertIcon />
@@ -131,9 +132,9 @@ export default function ChapterCard(props: IProps) {
onClose={handleClose} onClose={handleClose}
> >
{downloadStatusString.endsWith('Downloaded') {downloadStatusString.endsWith('Downloaded')
&& <MenuItem onClick={deleteChapter}>Delete</MenuItem>} && <MenuItem onClick={deleteChapter}>Delete</MenuItem>}
{downloadStatusString.length === 0 {downloadStatusString.length === 0
&& <MenuItem onClick={downloadChapter}>Download</MenuItem> } && <MenuItem onClick={downloadChapter}>Download</MenuItem> }
<MenuItem onClick={() => sendChange('bookmarked', !chapter.bookmarked)}> <MenuItem onClick={() => sendChange('bookmarked', !chapter.bookmarked)}>
{chapter.bookmarked && 'Remove bookmark'} {chapter.bookmarked && 'Remove bookmark'}
{!chapter.bookmarked && 'Bookmark'} {!chapter.bookmarked && 'Bookmark'}

View File

@@ -6,7 +6,6 @@
* 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, { useState } from 'react'; import React, { useState } from 'react';
import makeStyles from '@mui/styles/makeStyles';
import Card from '@mui/material/Card'; import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent'; import CardContent from '@mui/material/CardContent';
import Button from '@mui/material/Button'; import Button from '@mui/material/Button';
@@ -14,35 +13,7 @@ import Avatar from '@mui/material/Avatar';
import Typography from '@mui/material/Typography'; import Typography from '@mui/material/Typography';
import client from 'util/client'; import client from 'util/client';
import useLocalStorage from 'util/useLocalStorage'; import useLocalStorage from 'util/useLocalStorage';
import { Box } from '@mui/system';
const useStyles = makeStyles((theme) => ({
root: {
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
padding: 16,
},
bullet: {
display: 'inline-block',
margin: '0 2px',
transform: 'scale(0.8)',
},
title: {
fontSize: 14,
},
pos: {
marginBottom: 12,
},
icon: {
width: theme.spacing(7),
height: theme.spacing(7),
flex: '0 0 auto',
marginRight: 16,
},
card: {
margin: '10px',
},
}));
interface IProps { interface IProps {
extension: IExtension extension: IExtension
@@ -67,7 +38,6 @@ export default function ExtensionCard(props: IProps) {
const [serverAddress] = useLocalStorage<String>('serverBaseURL', ''); const [serverAddress] = useLocalStorage<String>('serverBaseURL', '');
const [useCache] = useLocalStorage<boolean>('useCache', true); const [useCache] = useLocalStorage<boolean>('useCache', true);
const classes = useStyles();
const langPress = lang === 'all' ? 'All' : lang.toUpperCase(); const langPress = lang === 'all' ? 'All' : lang.toUpperCase();
function install() { function install() {
@@ -118,16 +88,27 @@ export default function ExtensionCard(props: IProps) {
} }
return ( return (
<Card className={classes.card}> <Card sx={{ margin: '10px' }}>
<CardContent className={classes.root}> <CardContent sx={{
<div style={{ display: 'flex' }}> display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
p: 2,
}}
>
<Box sx={{ display: 'flex' }}>
<Avatar <Avatar
variant="rounded" variant="rounded"
className={classes.icon} sx={{
width: '56px',
height: '56px',
flex: '0 0 auto',
mr: 2,
}}
alt={name} alt={name}
src={`${serverAddress}${iconUrl}?useCache=${useCache}`} src={`${serverAddress}${iconUrl}?useCache=${useCache}`}
/> />
<div style={{ display: 'flex', flexDirection: 'column' }}> <Box sx={{ display: 'flex', flexDirection: 'column' }}>
<Typography variant="h5" component="h2"> <Typography variant="h5" component="h2">
{name} {name}
</Typography> </Typography>
@@ -136,8 +117,8 @@ export default function ExtensionCard(props: IProps) {
{' '} {' '}
{versionName} {versionName}
</Typography> </Typography>
</div> </Box>
</div> </Box>
<Button <Button
variant="outlined" variant="outlined"

View File

@@ -6,7 +6,6 @@
* 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 from 'react'; import React from 'react';
import makeStyles from '@mui/styles/makeStyles';
import Card from '@mui/material/Card'; import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent'; import CardContent from '@mui/material/CardContent';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
@@ -18,55 +17,7 @@ import Avatar from '@mui/material/Avatar';
import Typography from '@mui/material/Typography'; import Typography from '@mui/material/Typography';
import useLocalStorage from 'util/useLocalStorage'; import useLocalStorage from 'util/useLocalStorage';
import { langCodeToName } from 'util/language'; import { langCodeToName } from 'util/language';
import { Box } from '@mui/system';
const useStyles = makeStyles((theme) => ({
root: {
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
padding: 16,
},
bullet: {
display: 'inline-block',
margin: '0 2px',
transform: 'scale(0.8)',
},
title: {
fontSize: 14,
},
pos: {
marginBottom: 12,
},
icon: {
width: theme.spacing(7),
height: theme.spacing(7),
flex: '0 0 auto',
marginRight: 16,
},
card: {
margin: '10px',
'&:hover': {
backgroundColor: theme.palette.action.hover,
transition: 'background-color 100ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
},
'&:active': {
backgroundColor: theme.palette.action.selected,
transition: 'background-color 100ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
},
},
showMobile: {
display: 'flex',
[theme.breakpoints.up('sm')]: {
display: 'none',
},
},
showBigger: {
display: 'flex',
[theme.breakpoints.down('sm')]: {
display: 'none',
},
},
}));
interface IProps { interface IProps {
source: ISource source: ISource
@@ -84,8 +35,6 @@ export default function SourceCard(props: IProps) {
const [serverAddress] = useLocalStorage<String>('serverBaseURL', ''); const [serverAddress] = useLocalStorage<String>('serverBaseURL', '');
const [useCache] = useLocalStorage<boolean>('useCache', true); const [useCache] = useLocalStorage<boolean>('useCache', true);
const classes = useStyles();
const redirectTo = (e: any, to: string) => { const redirectTo = (e: any, to: string) => {
history.push(to); history.push(to);
@@ -95,19 +44,34 @@ export default function SourceCard(props: IProps) {
return ( return (
<Card <Card
className={classes.card} sx={{
margin: '10px',
'&:hover': {
backgroundColor: 'action.hover',
transition: 'background-color 100ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
},
'&:active': {
backgroundColor: 'action.selected',
transition: 'background-color 100ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
},
}}
onClick={(e) => redirectTo(e, `/sources/${id}/popular/`)} onClick={(e) => redirectTo(e, `/sources/${id}/popular/`)}
> >
<CardContent className={classes.root}> <CardContent sx={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
padding: 2,
}}
>
<div style={{ display: 'flex' }}> <Box sx={{ display: 'flex' }}>
<Avatar <Avatar
variant="rounded" variant="rounded"
className={classes.icon}
alt={name} alt={name}
src={`${serverAddress}${iconUrl}?useCache=${useCache}`} src={`${serverAddress}${iconUrl}?useCache=${useCache}`}
/> />
<div style={{ display: 'flex', flexDirection: 'column', justifyContent: 'center' }}> <Box sx={{ display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>
<Typography variant="h5" component="h2"> <Typography variant="h5" component="h2">
{name} {name}
</Typography> </Typography>
@@ -116,12 +80,12 @@ export default function SourceCard(props: IProps) {
{langCodeToName(lang)} {langCodeToName(lang)}
</Typography> </Typography>
)} )}
</div> </Box>
</div> </Box>
<div> <div>
<div className={classes.showMobile}> <Box sx={{ display: { xs: 'flex', sm: 'none' } }}>
<IconButton <IconButton
style={{ width: 59, height: 59 }} sx={{ width: 59, height: 59 }}
onClick={(e) => redirectTo(e, `/sources/${id}/search/`)} onClick={(e) => redirectTo(e, `/sources/${id}/search/`)}
size="large" size="large"
edge="end" edge="end"
@@ -140,11 +104,19 @@ export default function SourceCard(props: IProps) {
/> />
</IconButton> </IconButton>
)} )}
</div> </Box>
<div className={classes.showBigger}> <Box sx={{
display: {
xs: 'none',
sm: 'flex',
},
'> .MuiButton-root': {
ml: '20px',
},
}}
>
<Button <Button
variant="outlined" variant="outlined"
style={{ marginLeft: 20 }}
onClick={(e) => redirectTo(e, `/sources/${id}/search/`)} onClick={(e) => redirectTo(e, `/sources/${id}/search/`)}
> >
Search Search
@@ -152,7 +124,6 @@ export default function SourceCard(props: IProps) {
{supportsLatest && ( {supportsLatest && (
<Button <Button
variant="outlined" variant="outlined"
style={{ marginLeft: 20 }}
onClick={(e) => redirectTo(e, `/sources/${id}/latest/`)} onClick={(e) => redirectTo(e, `/sources/${id}/latest/`)}
> >
Latest Latest
@@ -160,12 +131,11 @@ export default function SourceCard(props: IProps) {
)} )}
<Button <Button
variant="outlined" variant="outlined"
style={{ marginLeft: 20 }}
onClick={(e: any) => redirectTo(e, `/sources/${id}/popular/`)} onClick={(e: any) => redirectTo(e, `/sources/${id}/popular/`)}
> >
Browse Browse
</Button> </Button>
</div> </Box>
</div> </div>
</CardContent> </CardContent>
</Card> </Card>

View File

@@ -11,16 +11,17 @@ import FilterListIcon from '@mui/icons-material/FilterList';
import { Drawer, FormControlLabel, IconButton } from '@mui/material'; import { Drawer, FormControlLabel, IconButton } from '@mui/material';
import useLibraryOptions from 'util/useLibraryOptions'; import useLibraryOptions from 'util/useLibraryOptions';
import ThreeStateCheckbox from 'components/util/ThreeStateCheckbox'; import ThreeStateCheckbox from 'components/util/ThreeStateCheckbox';
import { Box } from '@mui/system';
function Options() { function Options() {
const { const {
downloaded, setDownloaded, unread, setUnread, downloaded, setDownloaded, unread, setUnread,
} = useLibraryOptions(); } = useLibraryOptions();
return ( return (
<div style={{ display: 'flex', flexDirection: 'column' }}> <Box sx={{ display: 'flex', flexDirection: 'column' }}>
<FormControlLabel control={<ThreeStateCheckbox name="Unread" checked={unread} onChange={setUnread} />} label="Unread" /> <FormControlLabel control={<ThreeStateCheckbox name="Unread" checked={unread} onChange={setUnread} />} label="Unread" />
<FormControlLabel control={<ThreeStateCheckbox name="Downloaded" checked={downloaded} onChange={setDownloaded} />} label="Downloaded" /> <FormControlLabel control={<ThreeStateCheckbox name="Downloaded" checked={downloaded} onChange={setDownloaded} />} label="Downloaded" />
</div> </Box>
); );
} }

View File

@@ -11,7 +11,6 @@ import KeyboardArrowLeftIcon from '@mui/icons-material/KeyboardArrowLeft';
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight'; import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'; import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
import makeStyles from '@mui/styles/makeStyles';
import React, { useContext, useEffect, useState } from 'react'; import React, { useContext, useEffect, useState } from 'react';
import Typography from '@mui/material/Typography'; import Typography from '@mui/material/Typography';
import { useHistory, Link } from 'react-router-dom'; import { useHistory, Link } from 'react-router-dom';
@@ -28,112 +27,91 @@ import ListItemSecondaryAction from '@mui/material/ListItemSecondaryAction';
import Collapse from '@mui/material/Collapse'; import Collapse from '@mui/material/Collapse';
import Button from '@mui/material/Button'; import Button from '@mui/material/Button';
import NavBarContext from 'components/context/NavbarContext'; import NavBarContext from 'components/context/NavbarContext';
import { styled } from '@mui/system';
const useStyles = (settings: IReaderSettings) => makeStyles((theme) => ({ const Root = styled('div')(({ theme }) => ({
// main container and root div need to change classes... top: 0,
AppMainContainer: { left: 0,
display: 'none', width: '300px',
}, minWidth: '300px',
AppRootElment: { height: '100vh',
overflowY: 'auto',
backgroundColor: theme.palette.background.default,
'& header': {
backgroundColor:
theme.palette.mode === 'dark' ? theme.palette.grey[800] : theme.palette.grey[100],
display: 'flex', display: 'flex',
}, alignItems: 'center',
minHeight: '64px',
paddingLeft: '24px',
paddingRight: '24px',
root: { transition: 'left 2s ease',
position: settings.staticNav ? 'sticky' : 'fixed',
top: 0,
left: 0,
width: '300px',
minWidth: '300px',
height: '100vh',
overflowY: 'auto',
backgroundColor: theme.palette.background.default,
'& header': { '& button': {
backgroundColor: flexGrow: 0,
theme.palette.mode === 'dark' ? theme.palette.grey[800] : theme.palette.grey[100], flexShrink: 0,
display: 'flex',
alignItems: 'center',
minHeight: '64px',
paddingLeft: '24px',
paddingRight: '24px',
transition: 'left 2s ease',
'& button': {
flexGrow: 0,
flexShrink: 0,
},
'& button:nth-child(1)': {
marginRight: '16px',
},
'& button:nth-child(3)': {
marginRight: '-12px',
},
'& h1': {
fontSize: '1.25rem',
flexGrow: 1,
},
}, },
'& hr': {
margin: '0 16px', '& button:nth-child(1)': {
height: '1px', marginRight: '16px',
border: '0', },
backgroundColor: theme.palette.mode === 'dark' ? theme.palette.grey[800] : theme.palette.grey[100],
'& button:nth-child(3)': {
marginRight: '-12px',
},
'& h1': {
fontSize: '1.25rem',
flexGrow: 1,
}, },
}, },
'& hr': {
navigation: {
margin: '0 16px', margin: '0 16px',
height: '1px',
'& > span:nth-child(1)': { border: '0',
textAlign: 'center', backgroundColor: theme.palette.mode === 'dark' ? theme.palette.grey[800] : theme.palette.grey[100],
display: 'block',
marginTop: '16px',
},
'& $navigationChapters': {
display: 'grid',
gridTemplateColumns: '1fr 1fr',
gridTemplateAreas: '"prev next"',
gridColumnGap: '5px',
margin: '10px 0',
'& a': {
flexGrow: 1,
textDecoration: 'none',
'& button': {
width: '100%',
padding: '5px 8px',
textTransform: 'none',
},
},
},
}, },
navigationChapters: {}, // dummy rule }));
settingsCollapsseHeader: { const Navigation = styled('div')({
'& span': { margin: '0 16px',
fontWeight: 'bold', '& > span:nth-child(1)': {
textAlign: 'center',
display: 'block',
marginTop: '16px',
},
});
const ChapterNavigation = styled('div')({
display: 'grid',
gridTemplateColumns: '1fr 1fr',
gap: '5px',
margin: '10px 0',
'& a': {
flexGrow: 1,
textDecoration: 'none',
'& button': {
width: '100%',
padding: '5px 8px',
textTransform: 'none',
}, },
}, },
});
openDrawerButton: { const OpenDrawerButton = styled(IconButton)(({ theme }) => ({
position: 'fixed', position: 'fixed',
top: 0 + 20, top: 0 + 20,
left: 10 + 20, left: 10 + 20,
height: '40px', height: '40px',
width: '40px', width: '40px',
borderRadius: 5, borderRadius: 5,
backgroundColor: theme.palette.mode === 'dark' ? 'black' : 'white', backgroundColor: theme.palette.mode === 'dark' ? 'black' : 'white',
'&:hover': {
'&:hover': { backgroundColor: theme.palette.mode === 'dark' ? theme.palette.grey[900] : theme.palette.grey[100],
backgroundColor: theme.palette.mode === 'dark' ? theme.palette.grey[900] : theme.palette.grey[100],
},
}, },
})); }));
@@ -168,8 +146,6 @@ export default function ReaderNavBar(props: IProps) {
const [prevScrollPos, setPrevScrollPos] = useState(0); const [prevScrollPos, setPrevScrollPos] = useState(0);
const [settingsCollapseOpen, setSettingsCollapseOpen] = useState(true); const [settingsCollapseOpen, setSettingsCollapseOpen] = useState(true);
const classes = useStyles(settings)();
const setSettingValue = (key: string, value: any) => setSettings({ ...settings, [key]: value }); const setSettingValue = (key: string, value: any) => setSettings({ ...settings, [key]: value });
const handleScroll = () => { const handleScroll = () => {
@@ -184,15 +160,16 @@ export default function ReaderNavBar(props: IProps) {
useEffect(() => { useEffect(() => {
window.addEventListener('scroll', handleScroll); window.addEventListener('scroll', handleScroll);
const rootEl = document.querySelector('#root')!; const rootEl:HTMLDivElement = document.querySelector('#root')!;
const mainContainer = document.querySelector('#appMainContainer')!; const mainContainer:HTMLDivElement = document.querySelector('#appMainContainer')!;
rootEl.classList.add(classes.AppRootElment); // main container and root div need to change styles...
mainContainer.classList.add(classes.AppMainContainer); rootEl.style.display = 'flex';
mainContainer.style.display = 'none';
return () => { return () => {
rootEl.classList.remove(classes.AppRootElment); rootEl.style.display = 'block';
mainContainer.classList.remove(classes.AppMainContainer); mainContainer.style.display = 'block';
window.removeEventListener('scroll', handleScroll); window.removeEventListener('scroll', handleScroll);
}; };
}, [handleScroll]);// handleScroll changes on every render }, [handleScroll]);// handleScroll changes on every render
@@ -207,7 +184,10 @@ export default function ReaderNavBar(props: IProps) {
mountOnEnter mountOnEnter
unmountOnExit unmountOnExit
> >
<div className={classes.root}> <Root sx={{
position: settings.staticNav ? 'sticky' : 'fixed',
}}
>
<header> <header>
<IconButton <IconButton
edge="start" edge="start"
@@ -234,7 +214,14 @@ export default function ReaderNavBar(props: IProps) {
<CloseIcon /> <CloseIcon />
</IconButton> </IconButton>
</header> </header>
<ListItem ContainerComponent="div" className={classes.settingsCollapsseHeader}> <ListItem
ContainerComponent="div"
sx={{
'& span': {
fontWeight: 'bold',
},
}}
>
<ListItemText primary="Reader Settings" /> <ListItemText primary="Reader Settings" />
<ListItemSecondaryAction> <ListItemSecondaryAction>
<IconButton <IconButton
@@ -330,16 +317,15 @@ export default function ReaderNavBar(props: IProps) {
</List> </List>
</Collapse> </Collapse>
<hr /> <hr />
<div className={classes.navigation}> <Navigation>
<span> <span>
{`Currently on page ${curPage + 1} of ${chapter.pageCount}`} {`Currently on page ${curPage + 1} of ${chapter.pageCount}`}
</span> </span>
<div className={classes.navigationChapters}> <ChapterNavigation>
{chapter.index > 1 {chapter.index > 1
&& ( && (
<Link <Link
replace replace
style={{ gridArea: 'prev' }}
to={`/manga/${manga.id}/chapter/${chapter.index - 1}`} to={`/manga/${manga.id}/chapter/${chapter.index - 1}`}
> >
<Button <Button
@@ -354,7 +340,6 @@ export default function ReaderNavBar(props: IProps) {
&& ( && (
<Link <Link
replace replace
style={{ gridArea: 'next' }}
to={`/manga/${manga.id}/chapter/${chapter.index + 1}`} to={`/manga/${manga.id}/chapter/${chapter.index + 1}`}
> >
<Button <Button
@@ -365,14 +350,13 @@ export default function ReaderNavBar(props: IProps) {
</Button> </Button>
</Link> </Link>
)} )}
</div> </ChapterNavigation>
</div> </Navigation>
</div> </Root>
</Slide> </Slide>
<Zoom in={!drawerOpen}> <Zoom in={!drawerOpen}>
<Fade in={!hideOpenButton}> <Fade in={!hideOpenButton}>
<IconButton <OpenDrawerButton
className={classes.openDrawerButton}
edge="start" edge="start"
color="inherit" color="inherit"
aria-label="menu" aria-label="menu"
@@ -382,7 +366,7 @@ export default function ReaderNavBar(props: IProps) {
size="large" size="large"
> >
<KeyboardArrowRightIcon /> <KeyboardArrowRightIcon />
</IconButton> </OpenDrawerButton>
</Fade> </Fade>
</Zoom> </Zoom>
</> </>

View File

@@ -6,8 +6,6 @@
* 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 } from 'react'; import React, { useEffect, useState } from 'react';
import makeStyles from '@mui/styles/makeStyles';
import createStyles from '@mui/styles/createStyles';
import Button from '@mui/material/Button'; import Button from '@mui/material/Button';
import DialogTitle from '@mui/material/DialogTitle'; import DialogTitle from '@mui/material/DialogTitle';
import DialogContent from '@mui/material/DialogContent'; import DialogContent from '@mui/material/DialogContent';
@@ -18,13 +16,6 @@ import FormControlLabel from '@mui/material/FormControlLabel';
import FormGroup from '@mui/material/FormGroup'; import FormGroup from '@mui/material/FormGroup';
import client from 'util/client'; import client from 'util/client';
const useStyles = makeStyles(() => createStyles({
paper: {
maxHeight: 435,
width: '80%',
},
}));
interface IProps { interface IProps {
open: boolean open: boolean
setOpen: (value: boolean) => void setOpen: (value: boolean) => void
@@ -37,7 +28,6 @@ interface ICategoryInfo {
} }
export default function CategorySelect(props: IProps) { export default function CategorySelect(props: IProps) {
const classes = useStyles();
const { open, setOpen, mangaId } = props; const { open, setOpen, mangaId } = props;
const [categoryInfos, setCategoryInfos] = useState<ICategoryInfo[]>([]); const [categoryInfos, setCategoryInfos] = useState<ICategoryInfo[]>([]);
@@ -82,7 +72,12 @@ export default function CategorySelect(props: IProps) {
return ( return (
<Dialog <Dialog
classes={classes} sx={{
'.MuiDialog-paper': {
maxHeight: 435,
width: '80%',
},
}}
maxWidth="xs" maxWidth="xs"
open={open} open={open}
> >

View File

@@ -6,8 +6,6 @@
* 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, { useState } from 'react'; import React, { useState } from 'react';
import makeStyles from '@mui/styles/makeStyles';
import createStyles from '@mui/styles/createStyles';
import Button from '@mui/material/Button'; import Button from '@mui/material/Button';
import DialogTitle from '@mui/material/DialogTitle'; import DialogTitle from '@mui/material/DialogTitle';
import DialogContent from '@mui/material/DialogContent'; import DialogContent from '@mui/material/DialogContent';
@@ -21,13 +19,6 @@ import ListItem from '@mui/material/ListItem';
import { langCodeToName } from 'util/language'; import { langCodeToName } from 'util/language';
import cloneObject from 'util/cloneObject'; import cloneObject from 'util/cloneObject';
const useStyles = makeStyles(() => createStyles({
paper: {
maxHeight: 435,
width: '80%',
},
}));
function removeAll(firstList: any[], secondList: any[]) { function removeAll(firstList: any[], secondList: any[]) {
secondList.forEach((item) => { secondList.forEach((item) => {
const index = firstList.indexOf(item); const index = firstList.indexOf(item);
@@ -54,7 +45,6 @@ export default function LangSelect(props: IProps) {
const [mShownLangs, setMShownLangs] = useState( const [mShownLangs, setMShownLangs] = useState(
removeAll(cloneObject(shownLangs), forcedLangs!), removeAll(cloneObject(shownLangs), forcedLangs!),
); );
const classes = useStyles();
const [open, setOpen] = useState<boolean>(false); const [open, setOpen] = useState<boolean>(false);
const handleCancel = () => { const handleCancel = () => {
@@ -90,12 +80,17 @@ export default function LangSelect(props: IProps) {
<FilterListIcon /> <FilterListIcon />
</IconButton> </IconButton>
<Dialog <Dialog
classes={classes} sx={{
'.MuiDialog-paper': {
maxHeight: 435,
width: '80%',
},
}}
maxWidth="xs" maxWidth="xs"
open={open} open={open}
> >
<DialogTitle>Enabled Languages</DialogTitle> <DialogTitle>Enabled Languages</DialogTitle>
<DialogContent dividers style={{ padding: 0 }}> <DialogContent dividers sx={{ padding: 0 }}>
<List> <List>
{allLangs.map((lang) => ( {allLangs.map((lang) => (
<ListItem key={lang}> <ListItem key={lang}>

View File

@@ -45,7 +45,7 @@ export default function DesktopSideBar({ navBarItems }: IProps) {
}: NavbarItem) => ( }: NavbarItem) => (
<Link to={path} style={{ color: 'inherit', textDecoration: 'none' }} key={path}> <Link to={path} style={{ color: 'inherit', textDecoration: 'none' }} key={path}>
<ListItem disableRipple button key={title}> <ListItem disableRipple button key={title}>
<ListItemIcon style={{ minWidth: '0' }}> <ListItemIcon sx={{ minWidth: '0' }}>
<Tooltip placement="right" title={title}> <Tooltip placement="right" title={title}>
{iconFor(path, IconComponent, SelectedIconComponent)} {iconFor(path, IconComponent, SelectedIconComponent)}
</Tooltip> </Tooltip>

View File

@@ -5,28 +5,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import makeStyles from '@mui/styles/makeStyles';
import React from 'react'; import React from 'react';
import { Box, styled } from '@mui/system';
const useStyles = (settings: IReaderSettings) => makeStyles({ const Image = styled('img')({
image: { marginBottom: 0,
display: 'block', width: 'auto',
marginBottom: 0, minHeight: '99vh',
width: 'auto', height: 'auto',
minHeight: '99vh', maxHeight: '99vh',
height: 'auto', objectFit: 'contain',
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 { interface IProps {
@@ -41,21 +29,28 @@ const DoublePage = React.forwardRef((props: IProps, ref: any) => {
image1src, image2src, index, settings, image1src, image2src, index, settings,
} = props; } = props;
const classes = useStyles(settings)();
return ( return (
<div ref={ref} className={classes.page}> <Box
<img ref={ref}
className={classes.image} sx={{
display: 'flex',
flexDirection: settings.readerType === 'DoubleLTR' ? 'row' : 'row-reverse',
justifyContent: 'center',
margin: '0 auto',
width: 'auto',
height: 'auto',
overflowX: 'scroll',
}}
>
<Image
src={image1src} src={image1src}
alt={`Page #${index}`} alt={`Page #${index}`}
/> />
<img <Image
className={classes.image}
src={image2src} src={image2src}
alt={`Page #${index + 1}`} alt={`Page #${index + 1}`}
/> />
</div> </Box>
); );
}); });

View File

@@ -5,7 +5,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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 React, { useEffect, useRef } from 'react';
import SpinnerImage from 'components/util/SpinnerImage'; import SpinnerImage from 'components/util/SpinnerImage';
import useLocalStorage from 'util/useLocalStorage'; import useLocalStorage from 'util/useLocalStorage';
@@ -53,22 +52,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 { interface IProps {
src: string src: string
index: number index: number
@@ -84,7 +67,6 @@ const Page = React.forwardRef((props: IProps, ref: any) => {
const [useCache] = useLocalStorage<boolean>('useCache', true); const [useCache] = useLocalStorage<boolean>('useCache', true);
const classes = useStyles(settings)();
const imgRef = useRef<HTMLImageElement>(null); const imgRef = useRef<HTMLImageElement>(null);
const handleVerticalScroll = () => { const handleVerticalScroll = () => {
@@ -127,8 +109,14 @@ const Page = React.forwardRef((props: IProps, ref: any) => {
onImageLoad={onImageLoad} onImageLoad={onImageLoad}
alt={`Page #${index}`} alt={`Page #${index}`}
imgRef={imgRef} imgRef={imgRef}
spinnerClassName={`${classes.image} ${classes.loadingImage}`} spinnerStyle={{
imgClassName={classes.image} height: '100vh',
width: '70vw',
padding: '50px calc(50% - 20px)',
backgroundColor: '#525252',
marginBottom: 10,
}}
imgStyle={imageStyle(settings)}
/> />
</div> </div>
); );

View File

@@ -5,21 +5,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import makeStyles from '@mui/styles/makeStyles';
import React from 'react'; import React from 'react';
import { Box } from '@mui/system';
const useStyles = (settings: IReaderSettings) => makeStyles({
pageNumber: {
display: settings.showPageNumber ? 'block' : 'none',
position: 'fixed',
bottom: '50px',
right: settings.staticNav ? 'calc((100vw - 325px)/2)' : 'calc((100vw - 25px)/2)',
padding: '2px',
textAlign: 'center',
backgroundColor: 'rgba(0, 0, 0, 0.3)',
borderRadius: '10px',
},
});
interface IProps { interface IProps {
settings: IReaderSettings settings: IReaderSettings
@@ -29,11 +16,20 @@ interface IProps {
export default function PageNumber(props: IProps) { export default function PageNumber(props: IProps) {
const { settings, curPage, pageCount } = props; const { settings, curPage, pageCount } = props;
const classes = useStyles(settings)();
return ( return (
<div className={classes.pageNumber}> <Box sx={{
display: settings.showPageNumber ? 'block' : 'none',
position: 'fixed',
bottom: '50px',
right: settings.staticNav ? 'calc((100vw - 325px)/2)' : 'calc((100vw - 25px)/2)',
padding: '2px',
textAlign: 'center',
backgroundColor: 'rgba(0, 0, 0, 0.3)',
borderRadius: '10px',
}}
>
{`${curPage + 1} / ${pageCount}`} {`${curPage + 1} / ${pageCount}`}
</div> </Box>
); );
} }

View File

@@ -5,34 +5,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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 React, { useEffect, useRef } from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { Box } from '@mui/system';
import Page from '../Page'; import Page from '../Page';
import DoublePage from '../DoublePage'; import DoublePage from '../DoublePage';
const useStyles = (settings: IReaderSettings) => makeStyles({
preload: {
display: 'none',
},
reader: {
display: 'flex',
flexDirection: (settings.readerType === 'DoubleLTR') ? 'row' : 'row-reverse',
justifyContent: 'center',
margin: '0 auto',
width: 'auto',
height: 'auto',
overflowX: 'scroll',
},
});
export default function DoublePagedPager(props: IReaderProps) { export default function DoublePagedPager(props: IReaderProps) {
const { const {
pages, settings, setCurPage, curPage, nextChapter, prevChapter, pages, settings, setCurPage, curPage, nextChapter, prevChapter,
} = props; } = props;
const classes = useStyles(settings)();
const selfRef = useRef<HTMLDivElement>(null); const selfRef = useRef<HTMLDivElement>(null);
const pagesRef = useRef<HTMLImageElement[]>([]); const pagesRef = useRef<HTMLImageElement[]>([]);
@@ -192,8 +175,8 @@ export default function DoublePagedPager(props: IReaderProps) {
}, [selfRef, curPage, settings.readerType]); }, [selfRef, curPage, settings.readerType]);
return ( return (
<div ref={selfRef}> <Box ref={selfRef}>
<div id="preload" className={classes.preload}> <Box id="preload" sx={{ display: 'none' }}>
{ {
pages.map((page) => ( pages.map((page) => (
<img <img
@@ -205,8 +188,19 @@ export default function DoublePagedPager(props: IReaderProps) {
/> />
)) ))
} }
</div> </Box>
<div id="display" className={classes.reader} /> <Box
</div> id="display"
sx={{
display: 'flex',
flexDirection: (settings.readerType === 'DoubleLTR') ? 'row' : 'row-reverse',
justifyContent: 'center',
margin: '0 auto',
width: 'auto',
height: 'auto',
overflowX: 'scroll',
}}
/>
</Box>
); );
} }

View File

@@ -5,30 +5,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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 React, { useEffect, useRef } from 'react';
import { Box } from '@mui/system';
import Page from '../Page'; import Page from '../Page';
const useStyles = (settings: IReaderSettings) => makeStyles({
reader: {
display: 'flex',
flexDirection: (settings.readerType === 'ContinuesHorizontalLTR') ? 'row' : 'row-reverse',
justifyContent: (settings.readerType === 'ContinuesHorizontalLTR') ? 'flex-start' : 'flex-end',
margin: '0 auto',
width: 'auto',
height: 'auto',
overflowX: 'visible',
userSelect: 'none',
},
});
export default function HorizontalPager(props: IReaderProps) { export default function HorizontalPager(props: IReaderProps) {
const { const {
pages, curPage, settings, setCurPage, prevChapter, nextChapter, pages, curPage, settings, setCurPage, prevChapter, nextChapter,
} = props; } = props;
const classes = useStyles(settings)();
const selfRef = useRef<HTMLDivElement>(null); const selfRef = useRef<HTMLDivElement>(null);
const pagesRef = useRef<HTMLDivElement[]>([]); const pagesRef = useRef<HTMLDivElement[]>([]);
@@ -128,7 +113,19 @@ export default function HorizontalPager(props: IReaderProps) {
}, [selfRef, curPage]); }, [selfRef, curPage]);
return ( return (
<div ref={selfRef} className={classes.reader}> <Box
ref={selfRef}
sx={{
display: 'flex',
flexDirection: (settings.readerType === 'ContinuesHorizontalLTR') ? 'row' : 'row-reverse',
justifyContent: (settings.readerType === 'ContinuesHorizontalLTR') ? 'flex-start' : 'flex-end',
margin: '0 auto',
width: 'auto',
height: 'auto',
overflowX: 'visible',
userSelect: 'none',
}}
>
{ {
pages.map((page) => ( pages.map((page) => (
<Page <Page
@@ -142,6 +139,6 @@ export default function HorizontalPager(props: IReaderProps) {
/> />
)) ))
} }
</div> </Box>
); );
} }

View File

@@ -5,28 +5,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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 React, { useEffect, useRef } from 'react';
import { Box } from '@mui/system';
import Page from '../Page'; import Page from '../Page';
const useStyles = makeStyles({
reader: {
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
margin: '0 auto',
width: '100%',
height: '100vh',
},
});
export default function PagedReader(props: IReaderProps) { export default function PagedReader(props: IReaderProps) {
const { const {
pages, settings, setCurPage, curPage, nextChapter, prevChapter, pages, settings, setCurPage, curPage, nextChapter, prevChapter,
} = props; } = props;
const classes = useStyles();
const selfRef = useRef<HTMLDivElement>(null); const selfRef = useRef<HTMLDivElement>(null);
function nextPage() { function nextPage() {
@@ -97,7 +84,17 @@ export default function PagedReader(props: IReaderProps) {
}, [selfRef, curPage, settings.readerType]); }, [selfRef, curPage, settings.readerType]);
return ( return (
<div ref={selfRef} className={classes.reader}> <Box
ref={selfRef}
sx={{
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
margin: '0 auto',
width: '100%',
height: '100vh',
}}
>
<Page <Page
key={curPage} key={curPage}
index={curPage} index={curPage}
@@ -106,6 +103,6 @@ export default function PagedReader(props: IReaderProps) {
setCurPage={setCurPage} setCurPage={setCurPage}
settings={settings} settings={settings}
/> />
</div> </Box>
); );
} }

View File

@@ -5,27 +5,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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 React, { useEffect, useRef } from 'react';
import { Box } from '@mui/system';
import Page from '../Page'; import Page from '../Page';
const useStyles = makeStyles({
reader: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
margin: '0 auto',
width: '100%',
},
});
export default function VerticalReader(props: IReaderProps) { export default function VerticalReader(props: IReaderProps) {
const { const {
pages, settings, setCurPage, curPage, chapter, nextChapter, prevChapter, pages, settings, setCurPage, curPage, chapter, nextChapter, prevChapter,
} = props; } = props;
const classes = useStyles();
const selfRef = useRef<HTMLDivElement>(null); const selfRef = useRef<HTMLDivElement>(null);
const pagesRef = useRef<HTMLDivElement[]>([]); const pagesRef = useRef<HTMLDivElement[]>([]);
@@ -111,7 +99,16 @@ export default function VerticalReader(props: IReaderProps) {
}, [pagesRef.current.length]); }, [pagesRef.current.length]);
return ( return (
<div ref={selfRef} className={classes.reader}> <Box
ref={selfRef}
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
margin: '0 auto',
width: '100%',
}}
>
{ {
pages.map((page) => ( pages.map((page) => (
<Page <Page
@@ -125,6 +122,6 @@ export default function VerticalReader(props: IReaderProps) {
/> />
)) ))
} }
</div> </Box>
); );
} }

View File

@@ -10,6 +10,7 @@ import React from 'react';
import Typography from '@mui/material/Typography'; import Typography from '@mui/material/Typography';
import { useTheme } from '@mui/material/styles'; import { useTheme } from '@mui/material/styles';
import { useMediaQuery } from '@mui/material'; import { useMediaQuery } from '@mui/material';
import { Box } from '@mui/system';
const ERROR_FACES = [ const ERROR_FACES = [
'(・o・;)', '(・o・;)',
@@ -35,7 +36,7 @@ export default function EmptyView({ message, messageExtra }: IProps) {
const isMobileWidth = useMediaQuery(theme.breakpoints.down('sm')); const isMobileWidth = useMediaQuery(theme.breakpoints.down('sm'));
return ( return (
<div style={{ <Box sx={{
position: 'absolute', position: 'absolute',
left: `calc(50% + ${isMobileWidth ? '0px' : theme.spacing(8 / 2)})`, left: `calc(50% + ${isMobileWidth ? '0px' : theme.spacing(8 / 2)})`,
top: '50%', top: '50%',
@@ -50,7 +51,7 @@ export default function EmptyView({ message, messageExtra }: IProps) {
{message} {message}
</Typography> </Typography>
{messageExtra} {messageExtra}
</div> </Box>
); );
} }

View File

@@ -8,16 +8,8 @@
* 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 from 'react'; import React from 'react';
import makeStyles from '@mui/styles/makeStyles';
import CircularProgress from '@mui/material/CircularProgress'; import CircularProgress from '@mui/material/CircularProgress';
import { Box } from '@mui/system';
const useStyles = makeStyles({
loading: {
margin: '10px auto',
display: 'flex',
justifyContent: 'center',
},
});
interface IProps { interface IProps {
shouldRender?: boolean | (() => boolean) shouldRender?: boolean | (() => boolean)
@@ -30,7 +22,6 @@ export default function LoadingPlaceholder(props: IProps) {
const { const {
children, shouldRender, component, componentProps, children, shouldRender, component, componentProps,
} = props; } = props;
const classes = useStyles();
let condition = true; let condition = true;
if (shouldRender !== undefined) { if (shouldRender !== undefined) {
@@ -52,8 +43,13 @@ export default function LoadingPlaceholder(props: IProps) {
} }
return ( return (
<div className={classes.loading}> <Box sx={{
margin: '10px auto',
display: 'flex',
justifyContent: 'center',
}}
>
<CircularProgress thickness={5} /> <CircularProgress thickness={5} />
</div> </Box>
); );
} }

View File

@@ -17,9 +17,7 @@ interface IProps {
imgRef?: React.RefObject<HTMLImageElement> imgRef?: React.RefObject<HTMLImageElement>
spinnerClassName?: string
spinnerStyle?: SxProps<Theme> spinnerStyle?: SxProps<Theme>
imgClassName?: string
imgStyle?: CSSProperties imgStyle?: CSSProperties
onImageLoad?: () => void onImageLoad?: () => void
@@ -27,7 +25,7 @@ interface IProps {
export default function SpinnerImage(props: IProps) { export default function SpinnerImage(props: IProps) {
const { const {
src, alt, onImageLoad, imgRef, spinnerClassName, imgClassName, spinnerStyle, imgStyle, src, alt, onImageLoad, imgRef, spinnerStyle, imgStyle,
} = props; } = props;
const [imageSrc, setImagsrc] = useState<string>(''); const [imageSrc, setImagsrc] = useState<string>('');
@@ -53,19 +51,18 @@ export default function SpinnerImage(props: IProps) {
if (imageSrc.length === 0) { if (imageSrc.length === 0) {
return ( return (
<Box className={spinnerClassName} sx={spinnerStyle}> <Box sx={spinnerStyle}>
<CircularProgress thickness={5} /> <CircularProgress thickness={5} />
</Box> </Box>
); );
} }
if (imageSrc === 'Not Found') { if (imageSrc === 'Not Found') {
return <Box className={spinnerClassName} sx={spinnerStyle} />; return <Box sx={spinnerStyle} />;
} }
return ( return (
<img <img
className={imgClassName}
style={imgStyle} style={imgStyle}
ref={imgRef} ref={imgRef}
src={imageSrc} src={imageSrc}
@@ -75,8 +72,6 @@ export default function SpinnerImage(props: IProps) {
} }
SpinnerImage.defaultProps = { SpinnerImage.defaultProps = {
spinnerClassName: '',
imgClassName: '',
spinnerStyle: {}, spinnerStyle: {},
imgStyle: {}, imgStyle: {},
onImageLoad: () => {}, onImageLoad: () => {},

View File

@@ -6,21 +6,13 @@
* 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, { useState } from 'react'; import React, { useState } from 'react';
import makeStyles from '@mui/styles/makeStyles';
import Tabs from '@mui/material/Tabs'; import Tabs from '@mui/material/Tabs';
import Tab from '@mui/material/Tab'; import Tab from '@mui/material/Tab';
import TabPanel from 'components/util/TabPanel'; import TabPanel from 'components/util/TabPanel';
import Sources from 'screens/Sources'; import Sources from 'screens/Sources';
import Extensions from 'screens/Extensions'; import Extensions from 'screens/Extensions';
const useStyles = makeStyles({
noCapitalize: {
textTransform: 'none',
},
});
export default function Browse() { export default function Browse() {
const classes = useStyles();
const [tabNum, setTabNum] = useState<number>(0); const [tabNum, setTabNum] = useState<number>(0);
return ( return (
@@ -35,8 +27,8 @@ export default function Browse() {
scrollButtons scrollButtons
allowScrollButtonsMobile allowScrollButtonsMobile
> >
<Tab className={classes.noCapitalize} label="Sources" /> <Tab sx={{ textTransform: 'none' }} label="Sources" />
<Tab className={classes.noCapitalize} label="Extensions" /> <Tab sx={{ textTransform: 'none' }} label="Extensions" />
</Tabs> </Tabs>
<TabPanel index={0} currentIndex={tabNum}> <TabPanel index={0} currentIndex={tabNum}>
<Sources /> <Sources />

View File

@@ -18,15 +18,9 @@ import LoadingPlaceholder from 'components/util/LoadingPlaceholder';
import makeToast from 'components/util/Toast'; 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';
import { Box } from '@mui/system';
const useStyles = makeStyles((theme: Theme) => ({ const useStyles = makeStyles((theme: Theme) => ({
root: {
[theme.breakpoints.up('md')]: {
display: 'flex',
},
overflow: 'hidden',
},
chapters: { chapters: {
listStyle: 'none', listStyle: 'none',
padding: 0, padding: 0,
@@ -37,12 +31,6 @@ const useStyles = makeStyles((theme: Theme) => ({
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');
@@ -153,7 +141,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}
@@ -166,7 +154,7 @@ export default function Manga() {
<Virtuoso <Virtuoso
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} className={classes.chapters}
totalCount={chapters.length} totalCount={chapters.length}
@@ -177,11 +165,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>
); );
} }

View File

@@ -6,7 +6,6 @@
* 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 CircularProgress from '@mui/material/CircularProgress'; import CircularProgress from '@mui/material/CircularProgress';
import makeStyles from '@mui/styles/makeStyles';
import React, { useContext, useEffect, useState } from 'react'; import React, { useContext, useEffect, useState } from 'react';
import { useHistory, useParams } from 'react-router-dom'; import { useHistory, useParams } from 'react-router-dom';
import HorizontalPager from 'components/reader/pager/HorizontalPager'; import HorizontalPager from 'components/reader/pager/HorizontalPager';
@@ -19,18 +18,7 @@ import NavbarContext from 'components/context/NavbarContext';
import client from 'util/client'; import client from 'util/client';
import useLocalStorage from 'util/useLocalStorage'; import useLocalStorage from 'util/useLocalStorage';
import cloneObject from 'util/cloneObject'; import cloneObject from 'util/cloneObject';
import { Box } from '@mui/system';
const useStyles = (settings: IReaderSettings) => makeStyles({
root: {
width: settings.staticNav ? 'calc(100vw - 300px)' : '100vw',
},
loading: {
margin: '50px auto',
display: 'flex',
justifyContent: 'center',
},
});
const getReaderComponent = (readerType: ReaderType) => { const getReaderComponent = (readerType: ReaderType) => {
switch (readerType) { switch (readerType) {
@@ -63,7 +51,6 @@ const initialChapter = () => ({ pageCount: -1, index: -1, chapterCount: 0 });
export default function Reader() { export default function Reader() {
const [settings, setSettings] = useLocalStorage<IReaderSettings>('readerSettings', defaultReaderSettings); const [settings, setSettings] = useLocalStorage<IReaderSettings>('readerSettings', defaultReaderSettings);
const classes = useStyles(settings)();
const history = useHistory(); const history = useHistory();
const [serverAddress] = useLocalStorage<String>('serverBaseURL', ''); const [serverAddress] = useLocalStorage<String>('serverBaseURL', '');
@@ -145,9 +132,12 @@ export default function Reader() {
// return spinner while chpater data is loading // return spinner while chpater data is loading
if (chapter.pageCount === -1) { if (chapter.pageCount === -1) {
return ( return (
<div className={classes.loading}> <Box sx={{
height: '100vh', width: '100vw', display: 'grid', placeItems: 'center',
}}
>
<CircularProgress thickness={5} /> <CircularProgress thickness={5} />
</div> </Box>
); );
} }
@@ -176,7 +166,7 @@ export default function Reader() {
const ReaderComponent = getReaderComponent(settings.readerType); const ReaderComponent = getReaderComponent(settings.readerType);
return ( return (
<div className={classes.root}> <Box sx={{ width: settings.staticNav ? 'calc(100vw - 300px)' : '100vw' }}>
<PageNumber <PageNumber
settings={settings} settings={settings}
curPage={curPage} curPage={curPage}
@@ -193,6 +183,6 @@ export default function Reader() {
nextChapter={nextChapter} nextChapter={nextChapter}
prevChapter={prevChapter} prevChapter={prevChapter}
/> />
</div> </Box>
); );
} }

View File

@@ -6,33 +6,19 @@
* 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, { useContext, useEffect, useState } from 'react'; import React, { useContext, useEffect, useState } from 'react';
import makeStyles from '@mui/styles/makeStyles';
import TextField from '@mui/material/TextField'; import TextField from '@mui/material/TextField';
import Button from '@mui/material/Button'; import Button from '@mui/material/Button';
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';
import MangaGrid from 'components/MangaGrid'; import MangaGrid from 'components/MangaGrid';
import NavbarContext from 'components/context/NavbarContext'; import NavbarContext from 'components/context/NavbarContext';
import client from 'util/client'; import client from 'util/client';
import { Box } from '@mui/system';
const useStyles = makeStyles((theme) => ({
root: {
margin: '20px 10px',
display: 'flex',
justifyContent: 'space-around',
width: '300px',
TextField: {
margin: theme.spacing(1),
width: '25ch',
},
},
}));
export default function SearchSingle() { export default function SearchSingle() {
const { setTitle, setAction } = useContext(NavbarContext); const { setTitle, setAction } = useContext(NavbarContext);
useEffect(() => { setTitle('Search'); setAction(<></>); }, []); useEffect(() => { setTitle('Search'); setAction(<></>); }, []);
const { sourceId } = useParams<{ sourceId: string }>(); const { sourceId } = useParams<{ sourceId: string }>();
const classes = useStyles();
const [error, setError] = useState<boolean>(false); const [error, setError] = useState<boolean>(false);
const [mangas, setMangas] = useState<IMangaCard[]>([]); const [mangas, setMangas] = useState<IMangaCard[]>([]);
const [message, setMessage] = useState<string>(''); const [message, setMessage] = useState<string>('');
@@ -89,10 +75,20 @@ export default function SearchSingle() {
return ( return (
<> <>
<div className={classes.root}> <Box sx={{
margin: '20px 10px',
display: 'flex',
justifyContent: 'space-around',
width: '300px',
}}
>
<TextField <TextField
inputRef={textInput} inputRef={textInput}
error={error} error={error}
sx={{
m: 1,
width: '25ch',
}}
id="filled-basic" id="filled-basic"
variant="filled" variant="filled"
size="small" size="small"
@@ -102,7 +98,7 @@ export default function SearchSingle() {
<Button variant="contained" color="primary" onClick={() => processInput()}> <Button variant="contained" color="primary" onClick={() => processInput()}>
Search Search
</Button> </Button>
</div> </Box>
{searchTerm.length > 0 {searchTerm.length > 0
&& ( && (
<MangaGrid <MangaGrid

View File

@@ -59,7 +59,7 @@ export default function Settings() {
return ( return (
<> <>
<List style={{ padding: 0 }}> <List sx={{ padding: 0 }}>
<ListItemLink href="/settings/categories"> <ListItemLink href="/settings/categories">
<ListItemIcon> <ListItemIcon>
<ListAltIcon /> <ListAltIcon />

View File

@@ -57,7 +57,7 @@ export default function SourceConfigure() {
return ( return (
<> <>
<List style={{ padding: 0 }}> <List sx={{ padding: 0 }}>
{sourcePreferences.map( {sourcePreferences.map(
(it, index) => { (it, index) => {
const props = cloneObject(it.props); const props = cloneObject(it.props);

View File

@@ -20,6 +20,7 @@ import client from 'util/client';
import useLocalStorage from 'util/useLocalStorage'; import useLocalStorage from 'util/useLocalStorage';
import EmptyView from 'components/util/EmptyView'; import EmptyView from 'components/util/EmptyView';
import LoadingPlaceholder from 'components/util/LoadingPlaceholder'; import LoadingPlaceholder from 'components/util/LoadingPlaceholder';
import { Box } from '@mui/system';
function epochToDate(epoch: number) { function epochToDate(epoch: number) {
const date = new Date(0); // The 0 there is the key, which sets the date to the epoch const date = new Date(0); // The 0 there is the key, which sets the date to the epoch
@@ -189,7 +190,7 @@ export default function Updates() {
padding: 2, padding: 2,
}} }}
> >
<div style={{ display: 'flex' }}> <Box sx={{ display: 'flex' }}>
<Avatar <Avatar
variant="rounded" variant="rounded"
sx={{ sx={{
@@ -201,7 +202,7 @@ export default function Updates() {
}} }}
src={`${serverAddress}${manga.thumbnailUrl}?useCache=${useCache}`} src={`${serverAddress}${manga.thumbnailUrl}?useCache=${useCache}`}
/> />
<div style={{ display: 'flex', flexDirection: 'column' }}> <Box sx={{ display: 'flex', flexDirection: 'column' }}>
<Typography variant="h5" component="h2"> <Typography variant="h5" component="h2">
{manga.title} {manga.title}
</Typography> </Typography>
@@ -209,8 +210,8 @@ export default function Updates() {
{chapter.name} {chapter.name}
{downloadStatusStringFor(chapter)} {downloadStatusStringFor(chapter)}
</Typography> </Typography>
</div> </Box>
</div> </Box>
{downloadStatusStringFor(chapter) === '' {downloadStatusStringFor(chapter) === ''
&& ( && (
<IconButton <IconButton

View File

@@ -1,26 +1,15 @@
import React, { useContext, useEffect, useState } from 'react'; import React, { useContext, useEffect, useState } from 'react';
import { CircularProgress } from '@mui/material'; import { CircularProgress } from '@mui/material';
import makeStyles from '@mui/styles/makeStyles';
import List from '@mui/material/List'; import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem'; import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText'; import ListItemText from '@mui/material/ListItemText';
import client from '../../util/client'; import { Box } from '@mui/system';
import ListItemLink from '../../components/util/ListItemLink'; import client from 'util/client';
import NavbarContext from '../../components/context/NavbarContext'; import ListItemLink from 'components/util/ListItemLink';
import NavbarContext from 'components/context/NavbarContext';
const useStyles = makeStyles({
loading: {
width: '100vw',
'& div': {
margin: '50px auto',
display: 'block',
},
},
});
export default function About() { export default function About() {
const { setTitle, setAction } = useContext(NavbarContext); const { setTitle, setAction } = useContext(NavbarContext);
const classes = useStyles();
const [about, setAbout] = useState<IAbout>(); const [about, setAbout] = useState<IAbout>();
@@ -36,9 +25,12 @@ export default function About() {
if (about === undefined) { if (about === undefined) {
return ( return (
<div className={classes.loading}> <Box sx={{
height: 'calc(100vh - 128px)', display: 'grid', placeItems: 'center',
}}
>
<CircularProgress thickness={5} /> <CircularProgress thickness={5} />
</div> </Box>
); );
} }

View File

@@ -67,7 +67,7 @@ export default function Backup() {
return ( return (
<> <>
<List style={{ padding: 0 }}> <List sx={{ padding: 0 }}>
<ListItemLink href={`${baseURL}/api/v1/backup/export/file`}> <ListItemLink href={`${baseURL}/api/v1/backup/export/file`}>
<ListItemText <ListItemText
primary="Create Backup" primary="Create Backup"