Skip to content
New issue

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

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

Already on GitHub? # to your account

Feature/update dependency mui to v5.x #332

Merged
merged 5 commits into from
Jun 4, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@emotion/styled": "^11.3.0",
"@fontsource/roboto": "^4.3.0",
"@mui/icons-material": "^5.0.5",
"@mui/material": "^5.0.6",
"@mui/material": "^5.13.3",
"axios": "^1.4.0",
"file-selector": "^0.2.4",
"i18next": "^22.4.9",
Expand Down
7 changes: 4 additions & 3 deletions src/components/MangaCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Card from '@mui/material/Card';
import CardActionArea from '@mui/material/CardActionArea';
import Typography from '@mui/material/Typography';
import { Link } from 'react-router-dom';
import { Avatar, CardContent, Grid, Box, styled } from '@mui/material';
import { Avatar, Box, CardContent, Grid, styled } from '@mui/material';
import useLocalStorage from 'util/useLocalStorage';
import SpinnerImage from 'components/util/SpinnerImage';
import { GridLayout, useLibraryOptionsContext } from 'components/context/LibraryOptionsContext';
Expand Down Expand Up @@ -92,9 +92,10 @@ const MangaCard = React.forwardRef<HTMLDivElement, IProps>((props: IProps, ref)
const mangaLinkTo = { pathname: `/manga/${id}/`, state: { backLink: BACK } };

if (gridLayout !== GridLayout.List) {
const cols = Math.ceil(dimensions / ItemWidth);
const columns = Math.ceil(dimensions / ItemWidth);
const columnsPerItem = 12 / columns;
return (
<Grid item columns={cols} xs={1}>
<Grid item xs={columnsPerItem}>
<Link to={mangaLinkTo} style={gridLayout === GridLayout.Comfortable ? { textDecoration: 'none' } : {}}>
<Box
sx={{
Expand Down
6 changes: 3 additions & 3 deletions src/components/navbar/navigation/DesktopSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React from 'react';
import { ListItem, ListItemIcon, Tooltip, styled } from '@mui/material';
import { ListItemIcon, Tooltip, styled, ListItemButton } from '@mui/material';
import { Link, useLocation } from 'react-router-dom';
import { useTheme } from '@mui/material/styles';
import { NavbarItem } from 'typings';
Expand Down Expand Up @@ -46,13 +46,13 @@ export default function DesktopSideBar({ navBarItems }: IProps) {
<SideNavBarContainer>
{navBarItems.map(({ path, title, IconComponent, SelectedIconComponent }: NavbarItem) => (
<Link to={path} style={{ color: 'inherit', textDecoration: 'none' }} key={path}>
<ListItem disableRipple button key={title}>
<ListItemButton disableRipple key={title}>
<ListItemIcon sx={{ minWidth: '0' }}>
<Tooltip placement="right" title={t(title)}>
{iconFor(path, IconComponent, SelectedIconComponent)}
</Tooltip>
</ListItemIcon>
</ListItem>
</ListItemButton>
</Link>
))}
</SideNavBarContainer>
Expand Down
6 changes: 3 additions & 3 deletions src/components/navbar/navigation/MobileBottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React from 'react';
import { ListItem, styled, Box } from '@mui/material';
import { styled, Box, ListItemButton } from '@mui/material';
import { Link as RRDLink, useLocation } from 'react-router-dom';
import { useTheme } from '@mui/material/styles';
import { NavbarItem } from 'typings';
Expand Down Expand Up @@ -55,7 +55,7 @@ export default function MobileBottomBar({ navBarItems }: IProps) {
<BottomNavContainer>
{navBarItems.map(({ path, title, IconComponent, SelectedIconComponent }: NavbarItem) => (
<Link to={path} key={path}>
<ListItem disableRipple button sx={{ justifyContent: 'center', padding: '8px' }} key={title}>
<ListItemButton disableRipple sx={{ justifyContent: 'center', padding: '8px' }} key={title}>
<Box display="flex" flexDirection="column" alignItems="center">
{iconFor(path, IconComponent, SelectedIconComponent)}
<Box
Expand All @@ -73,7 +73,7 @@ export default function MobileBottomBar({ navBarItems }: IProps) {
{t(title)}
</Box>
</Box>
</ListItem>
</ListItemButton>
</Link>
))}
</BottomNavContainer>
Expand Down
6 changes: 3 additions & 3 deletions src/components/sourceConfiguration/EditTextPreference.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import React, { useState } from 'react';
import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText';
import Dialog from '@mui/material/Dialog';
import DialogTitle from '@mui/material/DialogTitle';
Expand All @@ -18,6 +17,7 @@ import TextField from '@mui/material/TextField';
import Button from '@mui/material/Button';
import { EditTextPreferenceProps } from 'typings';
import { useTranslation } from 'react-i18next';
import { ListItemButton } from '@mui/material';

export default function EditTextPreference(props: EditTextPreferenceProps) {
const { t } = useTranslation();
Expand All @@ -42,9 +42,9 @@ export default function EditTextPreference(props: EditTextPreferenceProps) {

return (
<>
<ListItem button onClick={() => setDialogOpen(true)}>
<ListItemButton onClick={() => setDialogOpen(true)}>
<ListItemText primary={title} secondary={summary} />
</ListItem>
</ListItemButton>
<Dialog open={dialogOpen} onClose={handleDialogCancel}>
<DialogTitle>{dialogTitle}</DialogTitle>
<DialogContent>
Expand Down
6 changes: 3 additions & 3 deletions src/components/sourceConfiguration/ListPreference.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import React, { useState, useEffect } from 'react';
import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText';
import Dialog from '@mui/material/Dialog';
import DialogTitle from '@mui/material/DialogTitle';
Expand All @@ -19,6 +18,7 @@ import FormControlLabel from '@mui/material/FormControlLabel';
import Button from '@mui/material/Button';
import { ListPreferenceProps } from 'typings';
import { useTranslation } from 'react-i18next';
import { ListItemButton } from '@mui/material';

interface IListDialogProps {
value: string;
Expand Down Expand Up @@ -123,9 +123,9 @@ export default function ListPreference(props: ListPreferenceProps) {

return (
<>
<ListItem button onClick={() => setDialogOpen(true)}>
<ListItemButton onClick={() => setDialogOpen(true)}>
<ListItemText primary={title} secondary={getSummary()} />
</ListItem>
</ListItemButton>
<ListDialog
title={title}
open={dialogOpen}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import React, { useState, useEffect } from 'react';
import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText';
import Dialog from '@mui/material/Dialog';
import DialogTitle from '@mui/material/DialogTitle';
Expand All @@ -20,6 +19,7 @@ import Button from '@mui/material/Button';
import cloneObject from 'util/cloneObject';
import { MultiSelectListPreferenceProps } from 'typings';
import { useTranslation } from 'react-i18next';
import { ListItemButton } from '@mui/material';

interface IListDialogProps {
selectedValues: string[];
Expand Down Expand Up @@ -135,9 +135,9 @@ export default function MultiSelectListPreference(props: MultiSelectListPreferen

return (
<>
<ListItem button onClick={() => setDialogOpen(true)}>
<ListItemButton onClick={() => setDialogOpen(true)}>
<ListItemText primary={title} secondary={getSummary()} />
</ListItem>
</ListItemButton>
<ListDialog
title={title}
open={dialogOpen}
Expand Down
12 changes: 8 additions & 4 deletions src/components/util/ListItemLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
*/

import React from 'react';
import ListItem, { ListItemProps } from '@mui/material/ListItem';
import { Link } from 'react-router-dom';
import { ListItemButton, ListItemButtonProps } from '@mui/material';

export default function ListItemLink(props: ListItemProps<Link, { directLink?: boolean }>) {
export default function ListItemLink(props: ListItemButtonProps<typeof Link, { directLink?: boolean }>) {
const { directLink, to } = props;
if (directLink) {
return <ListItem button component="a" href={to} {...props} />;
if (typeof to !== 'string') {
throw new Error('ListItemLink: "to" has to be a string in case it is a directLink');
}

return <ListItemButton component="a" href={to} {...props} />;
}

return <ListItem button component={Link} {...props} />;
return <ListItemButton component={Link} {...props} />;
}
6 changes: 3 additions & 3 deletions src/screens/Reader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ const getReaderComponent = (readerType: ReaderType) => {
};

const range = (n: number) => Array.from({ length: n }, (value, key) => key);
const initialChapter = () => ({
const initialChapter = {
pageCount: -1,
index: -1,
chapterCount: 0,
lastPageRead: 0,
name: 'Loading...',
});
};

export default function Reader() {
const { t } = useTranslation();
Expand All @@ -103,7 +103,7 @@ export default function Reader() {
} as IMangaCard | IManga,
isLoading: isMangaLoading,
} = requestManager.useGetManga(mangaId);
const { data: chapter = initialChapter(), isLoading: isChapterLoading } = requestManager.useGetChapter(
const { data: chapter = initialChapter, isLoading: isChapterLoading } = requestManager.useGetChapter(
mangaId,
chapterIndex,
);
Expand Down
6 changes: 3 additions & 3 deletions src/screens/settings/Backup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

import React, { useContext, useEffect } from 'react';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText';
import { fromEvent } from 'file-selector';
import makeToast from 'components/util/Toast';
import ListItemLink from 'components/util/ListItemLink';
import NavbarContext from 'components/context/NavbarContext';
import { useTranslation } from 'react-i18next';
import requestManager from 'lib/RequestManager';
import { ListItemButton } from '@mui/material';

export default function Backup() {
const { t } = useTranslation();
Expand Down Expand Up @@ -75,12 +75,12 @@ export default function Backup() {
secondary={t('settings.backup.label.create_backup_info')}
/>
</ListItemLink>
<ListItem button onClick={() => document.getElementById('backup-file')?.click()}>
<ListItemButton onClick={() => document.getElementById('backup-file')?.click()}>
<ListItemText
primary={t('settings.backup.label.restore_backup')}
secondary={t('settings.backup.label.restore_backup_info')}
/>
</ListItem>
</ListItemButton>
</List>
<input type="file" id="backup-file" style={{ display: 'none' }} />
</>
Expand Down
Loading