Extract list card content
This commit is contained in:
24
src/modules/core/components/cards/list/ListCardContent.tsx
Normal file
24
src/modules/core/components/cards/list/ListCardContent.tsx
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* 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/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import CardContent, { CardContentProps } from '@mui/material/CardContent';
|
||||||
|
|
||||||
|
export const ListCardContent = ({ children, ...props }: CardContentProps) => (
|
||||||
|
<CardContent
|
||||||
|
{...props}
|
||||||
|
sx={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: 1,
|
||||||
|
p: 1.5,
|
||||||
|
...props.sx,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</CardContent>
|
||||||
|
);
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import Card from '@mui/material/Card';
|
import Card from '@mui/material/Card';
|
||||||
import CardContent from '@mui/material/CardContent';
|
|
||||||
import Button from '@mui/material/Button';
|
import Button from '@mui/material/Button';
|
||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@@ -35,6 +34,7 @@ import { getInstalledState } from '@/modules/extension/Extensions.utils.ts';
|
|||||||
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
|
||||||
import { CustomTooltip } from '@/modules/core/components/CustomTooltip';
|
import { CustomTooltip } from '@/modules/core/components/CustomTooltip';
|
||||||
import { ListCardAvatar } from '@/modules/core/components/cards/list/ListCardAvatar.tsx';
|
import { ListCardAvatar } from '@/modules/core/components/cards/list/ListCardAvatar.tsx';
|
||||||
|
import { ListCardContent } from '@/modules/core/components/cards/list/ListCardContent.tsx';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
extension: TExtension;
|
extension: TExtension;
|
||||||
@@ -118,17 +118,7 @@ export function ExtensionCard(props: IProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent
|
<ListCardContent>
|
||||||
sx={{
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
gap: 1,
|
|
||||||
p: 1.5,
|
|
||||||
'&:last-child': {
|
|
||||||
paddingBottom: 1.5,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListCardAvatar iconUrl={requestManager.getValidImgUrlFor(iconUrl)} alt={name} />
|
<ListCardAvatar iconUrl={requestManager.getValidImgUrlFor(iconUrl)} alt={name} />
|
||||||
<Stack
|
<Stack
|
||||||
sx={{
|
sx={{
|
||||||
@@ -168,7 +158,7 @@ export function ExtensionCard(props: IProps) {
|
|||||||
>
|
>
|
||||||
{t(INSTALLED_STATE_TO_TRANSLATION_KEY_MAP[installedState])}
|
{t(INSTALLED_STATE_TO_TRANSLATION_KEY_MAP[installedState])}
|
||||||
</Button>
|
</Button>
|
||||||
</CardContent>
|
</ListCardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import CardActionArea from '@mui/material/CardActionArea';
|
import CardActionArea from '@mui/material/CardActionArea';
|
||||||
import Card from '@mui/material/Card';
|
import Card from '@mui/material/Card';
|
||||||
import CardContent from '@mui/material/CardContent';
|
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { DownloadStateIndicator } from '@/modules/core/components/DownloadStateIndicator.tsx';
|
import { DownloadStateIndicator } from '@/modules/core/components/DownloadStateIndicator.tsx';
|
||||||
@@ -21,6 +20,7 @@ import { ChapterCardThumbnail } from '@/modules/chapter/components/cards/Chapter
|
|||||||
import { ChapterCardMetadata } from '@/modules/chapter/components/cards/ChapterCardMetadata.tsx';
|
import { ChapterCardMetadata } from '@/modules/chapter/components/cards/ChapterCardMetadata.tsx';
|
||||||
import { ChapterDownloadButton } from '@/modules/chapter/components/buttons/ChapterDownloadButton.tsx';
|
import { ChapterDownloadButton } from '@/modules/chapter/components/buttons/ChapterDownloadButton.tsx';
|
||||||
import { ChapterDownloadRetryButton } from '@/modules/chapter/components/buttons/ChapterDownloadRetryButton.tsx';
|
import { ChapterDownloadRetryButton } from '@/modules/chapter/components/buttons/ChapterDownloadRetryButton.tsx';
|
||||||
|
import { ListCardContent } from '@/modules/core/components/cards/list/ListCardContent';
|
||||||
|
|
||||||
export const ChapterHistoryCard = memo(({ chapter }: { chapter: ChapterHistoryListFieldsFragment }) => {
|
export const ChapterHistoryCard = memo(({ chapter }: { chapter: ChapterHistoryListFieldsFragment }) => {
|
||||||
const { manga } = chapter;
|
const { manga } = chapter;
|
||||||
@@ -35,14 +35,7 @@ export const ChapterHistoryCard = memo(({ chapter }: { chapter: ChapterHistoryLi
|
|||||||
color: (theme) => theme.palette.text[chapter.isRead ? 'disabled' : 'primary'],
|
color: (theme) => theme.palette.text[chapter.isRead ? 'disabled' : 'primary'],
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CardContent
|
<ListCardContent sx={{ justifyContent: 'space-between' }}>
|
||||||
sx={{
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
alignItems: 'center',
|
|
||||||
padding: 1.5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box sx={{ display: 'flex', flexGrow: 1, gap: 1 }}>
|
<Box sx={{ display: 'flex', flexGrow: 1, gap: 1 }}>
|
||||||
<ChapterCardThumbnail
|
<ChapterCardThumbnail
|
||||||
mangaId={manga.id}
|
mangaId={manga.id}
|
||||||
@@ -58,7 +51,7 @@ export const ChapterHistoryCard = memo(({ chapter }: { chapter: ChapterHistoryLi
|
|||||||
<DownloadStateIndicator chapterId={chapter.id} />
|
<DownloadStateIndicator chapterId={chapter.id} />
|
||||||
<ChapterDownloadRetryButton chapterId={chapter.id} />
|
<ChapterDownloadRetryButton chapterId={chapter.id} />
|
||||||
<ChapterDownloadButton chapterId={chapter.id} isDownloaded={chapter.isDownloaded} />
|
<ChapterDownloadButton chapterId={chapter.id} isDownloaded={chapter.isDownloaded} />
|
||||||
</CardContent>
|
</ListCardContent>
|
||||||
</CardActionArea>
|
</CardActionArea>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Card from '@mui/material/Card';
|
import Card from '@mui/material/Card';
|
||||||
import CardContent from '@mui/material/CardContent';
|
|
||||||
import CardActionArea from '@mui/material/CardActionArea';
|
import CardActionArea from '@mui/material/CardActionArea';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import Stack from '@mui/material/Stack';
|
import Stack from '@mui/material/Stack';
|
||||||
@@ -19,6 +18,7 @@ import { SpecificMangaCardProps } from '@/modules/manga/Manga.types.ts';
|
|||||||
import { Mangas } from '@/modules/manga/services/Mangas.ts';
|
import { Mangas } from '@/modules/manga/services/Mangas.ts';
|
||||||
import { MangaOptionButton } from '@/modules/manga/components/MangaOptionButton.tsx';
|
import { MangaOptionButton } from '@/modules/manga/components/MangaOptionButton.tsx';
|
||||||
import { ListCardAvatar } from '@/modules/core/components/cards/list/ListCardAvatar.tsx';
|
import { ListCardAvatar } from '@/modules/core/components/cards/list/ListCardAvatar.tsx';
|
||||||
|
import { ListCardContent } from '@/modules/core/components/cards/list/ListCardContent';
|
||||||
|
|
||||||
export const MangaListCard = memo(
|
export const MangaListCard = memo(
|
||||||
({
|
({
|
||||||
@@ -63,14 +63,10 @@ export const MangaListCard = memo(
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CardContent
|
<ListCardContent
|
||||||
sx={{
|
sx={{
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
alignItems: 'center',
|
|
||||||
padding: 1.5,
|
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
gap: 1,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ListCardAvatar
|
<ListCardAvatar
|
||||||
@@ -117,7 +113,7 @@ export const MangaListCard = memo(
|
|||||||
asCheckbox
|
asCheckbox
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</CardContent>
|
</ListCardContent>
|
||||||
</CardActionArea>
|
</CardActionArea>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Card from '@mui/material/Card';
|
import Card from '@mui/material/Card';
|
||||||
import CardContent from '@mui/material/CardContent';
|
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import CardActionArea from '@mui/material/CardActionArea';
|
import CardActionArea from '@mui/material/CardActionArea';
|
||||||
import Chip from '@mui/material/Chip';
|
import Chip from '@mui/material/Chip';
|
||||||
@@ -19,6 +18,7 @@ import { GetMigratableSourcesQuery } from '@/lib/graphql/generated/graphql.ts';
|
|||||||
import { translateExtensionLanguage } from '@/modules/extension/Extensions.utils.ts';
|
import { translateExtensionLanguage } from '@/modules/extension/Extensions.utils.ts';
|
||||||
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
|
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
|
||||||
import { ListCardAvatar } from '@/modules/core/components/cards/list/ListCardAvatar.tsx';
|
import { ListCardAvatar } from '@/modules/core/components/cards/list/ListCardAvatar.tsx';
|
||||||
|
import { ListCardContent } from '@/modules/core/components/cards/list/ListCardContent.tsx';
|
||||||
|
|
||||||
export type TMigratableSource = NonNullable<GetMigratableSourcesQuery['mangas']['nodes'][number]['source']> & {
|
export type TMigratableSource = NonNullable<GetMigratableSourcesQuery['mangas']['nodes'][number]['source']> & {
|
||||||
mangaCount: number;
|
mangaCount: number;
|
||||||
@@ -34,14 +34,7 @@ export const MigrationCard = ({ id, name, lang, iconUrl, mangaCount }: TMigratab
|
|||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardActionArea component={Link} to={AppRoutes.migrate.path(id)}>
|
<CardActionArea component={Link} to={AppRoutes.migrate.path(id)}>
|
||||||
<CardContent
|
<ListCardContent sx={{ justifyContent: 'space-between' }}>
|
||||||
sx={{
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
alignItems: 'center',
|
|
||||||
p: 1.5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box sx={{ display: 'flex', gap: 1 }}>
|
<Box sx={{ display: 'flex', gap: 1 }}>
|
||||||
<ListCardAvatar iconUrl={requestManager.getValidImgUrlFor(iconUrl)} alt={sourceName} />
|
<ListCardAvatar iconUrl={requestManager.getValidImgUrlFor(iconUrl)} alt={sourceName} />
|
||||||
<Box sx={{ display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>
|
<Box sx={{ display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>
|
||||||
@@ -59,7 +52,7 @@ export const MigrationCard = ({ id, name, lang, iconUrl, mangaCount }: TMigratab
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Chip sx={{ borderRadius: 1 }} size="small" label={mangaCount} />
|
<Chip sx={{ borderRadius: 1 }} size="small" label={mangaCount} />
|
||||||
</CardContent>
|
</ListCardContent>
|
||||||
</CardActionArea>
|
</CardActionArea>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
import CardActionArea from '@mui/material/CardActionArea';
|
import CardActionArea from '@mui/material/CardActionArea';
|
||||||
import Button from '@mui/material/Button';
|
import Button from '@mui/material/Button';
|
||||||
import Card from '@mui/material/Card';
|
import Card from '@mui/material/Card';
|
||||||
import CardContent from '@mui/material/CardContent';
|
|
||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@@ -24,6 +23,7 @@ import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
|
|||||||
import { MUIUtil } from '@/lib/mui/MUI.util.ts';
|
import { MUIUtil } from '@/lib/mui/MUI.util.ts';
|
||||||
import { Sources } from '@/modules/source/services/Sources.ts';
|
import { Sources } from '@/modules/source/services/Sources.ts';
|
||||||
import { ListCardAvatar } from '@/modules/core/components/cards/list/ListCardAvatar.tsx';
|
import { ListCardAvatar } from '@/modules/core/components/cards/list/ListCardAvatar.tsx';
|
||||||
|
import { ListCardContent } from '@/modules/core/components/cards/list/ListCardContent.tsx';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
source: GetSourcesListQuery['sources']['nodes'][number];
|
source: GetSourcesListQuery['sources']['nodes'][number];
|
||||||
@@ -60,14 +60,7 @@ export const SourceCard: React.FC<IProps> = (props: IProps) => {
|
|||||||
to={AppRoutes.sources.childRoutes.browse.path(id)}
|
to={AppRoutes.sources.childRoutes.browse.path(id)}
|
||||||
state={{ contentType: SourceContentType.POPULAR, clearCache: true }}
|
state={{ contentType: SourceContentType.POPULAR, clearCache: true }}
|
||||||
>
|
>
|
||||||
<CardContent
|
<ListCardContent>
|
||||||
sx={{
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
gap: 1,
|
|
||||||
p: 1.5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ListCardAvatar iconUrl={requestManager.getValidImgUrlFor(iconUrl)} alt={sourceName} />
|
<ListCardAvatar iconUrl={requestManager.getValidImgUrlFor(iconUrl)} alt={sourceName} />
|
||||||
<Stack
|
<Stack
|
||||||
sx={{
|
sx={{
|
||||||
@@ -112,7 +105,7 @@ export const SourceCard: React.FC<IProps> = (props: IProps) => {
|
|||||||
{t('global.button.popular')}
|
{t('global.button.popular')}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</ListCardContent>
|
||||||
</CardActionArea>
|
</CardActionArea>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import CardActionArea from '@mui/material/CardActionArea';
|
import CardActionArea from '@mui/material/CardActionArea';
|
||||||
import Card from '@mui/material/Card';
|
import Card from '@mui/material/Card';
|
||||||
import CardContent from '@mui/material/CardContent';
|
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { DownloadStateIndicator } from '@/modules/core/components/DownloadStateIndicator.tsx';
|
import { DownloadStateIndicator } from '@/modules/core/components/DownloadStateIndicator.tsx';
|
||||||
@@ -20,6 +19,7 @@ import { ChapterCardMetadata } from '@/modules/chapter/components/cards/ChapterC
|
|||||||
import { ChapterDownloadButton } from '@/modules/chapter/components/buttons/ChapterDownloadButton.tsx';
|
import { ChapterDownloadButton } from '@/modules/chapter/components/buttons/ChapterDownloadButton.tsx';
|
||||||
import { ChapterDownloadRetryButton } from '@/modules/chapter/components/buttons/ChapterDownloadRetryButton.tsx';
|
import { ChapterDownloadRetryButton } from '@/modules/chapter/components/buttons/ChapterDownloadRetryButton.tsx';
|
||||||
import { Chapters } from '@/modules/chapter/services/Chapters.ts';
|
import { Chapters } from '@/modules/chapter/services/Chapters.ts';
|
||||||
|
import { ListCardContent } from '@/modules/core/components/cards/list/ListCardContent.tsx';
|
||||||
|
|
||||||
export const ChapterUpdateCard = memo(({ chapter }: { chapter: ChapterUpdateListFieldsFragment }) => {
|
export const ChapterUpdateCard = memo(({ chapter }: { chapter: ChapterUpdateListFieldsFragment }) => {
|
||||||
const { manga } = chapter;
|
const { manga } = chapter;
|
||||||
@@ -34,14 +34,7 @@ export const ChapterUpdateCard = memo(({ chapter }: { chapter: ChapterUpdateList
|
|||||||
color: (theme) => theme.palette.text[chapter.isRead ? 'disabled' : 'primary'],
|
color: (theme) => theme.palette.text[chapter.isRead ? 'disabled' : 'primary'],
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CardContent
|
<ListCardContent sx={{ justifyContent: 'space-between' }}>
|
||||||
sx={{
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
alignItems: 'center',
|
|
||||||
padding: 1.5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box sx={{ display: 'flex', flexGrow: 1, gap: 1 }}>
|
<Box sx={{ display: 'flex', flexGrow: 1, gap: 1 }}>
|
||||||
<ChapterCardThumbnail
|
<ChapterCardThumbnail
|
||||||
mangaId={manga.id}
|
mangaId={manga.id}
|
||||||
@@ -54,7 +47,7 @@ export const ChapterUpdateCard = memo(({ chapter }: { chapter: ChapterUpdateList
|
|||||||
<DownloadStateIndicator chapterId={chapter.id} />
|
<DownloadStateIndicator chapterId={chapter.id} />
|
||||||
<ChapterDownloadRetryButton chapterId={chapter.id} />
|
<ChapterDownloadRetryButton chapterId={chapter.id} />
|
||||||
<ChapterDownloadButton chapterId={chapter.id} isDownloaded={chapter.isDownloaded} />
|
<ChapterDownloadButton chapterId={chapter.id} isDownloaded={chapter.isDownloaded} />
|
||||||
</CardContent>
|
</ListCardContent>
|
||||||
</CardActionArea>
|
</CardActionArea>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user