2021-03-26 04:17:02 +04:30
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
2021-01-26 23:32:12 +03:30
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2023-05-18 13:17:41 +02:00
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
2021-01-26 23:32:12 +03:30
|
|
|
|
2024-04-14 15:50:12 +02:00
|
|
|
import CardActionArea from '@mui/material/CardActionArea';
|
|
|
|
|
import Box from '@mui/material/Box';
|
2022-11-26 13:51:56 +01:00
|
|
|
import Avatar from '@mui/material/Avatar';
|
|
|
|
|
import Button from '@mui/material/Button';
|
2021-09-09 17:51:22 +04:30
|
|
|
import Card from '@mui/material/Card';
|
|
|
|
|
import CardContent from '@mui/material/CardContent';
|
|
|
|
|
import Typography from '@mui/material/Typography';
|
2022-11-26 13:51:56 +01:00
|
|
|
import React from 'react';
|
2023-03-23 13:59:32 +01:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-05-28 12:16:06 +02:00
|
|
|
import { Link } from 'react-router-dom';
|
2024-08-30 21:32:21 +02:00
|
|
|
import Stack from '@mui/material/Stack';
|
2024-10-05 16:09:34 +02:00
|
|
|
import { requestManager } from '@/lib/requests/requests/RequestManager.ts';
|
2024-10-05 21:29:50 +02:00
|
|
|
import { translateExtensionLanguage } from '@/modules/extension/services/Extensions.ts';
|
2024-10-05 21:22:12 +02:00
|
|
|
import { SourceContentType } from '@/modules/source/screens/SourceMangas.tsx';
|
2024-10-05 16:09:34 +02:00
|
|
|
import { SpinnerImage } from '@/modules/core/components/SpinnerImage.tsx';
|
2024-07-03 23:15:50 +02:00
|
|
|
import { GetSourcesListQuery } from '@/lib/graphql/generated/graphql.ts';
|
2024-08-30 21:32:21 +02:00
|
|
|
import { MediaQuery } from '@/lib/ui/MediaQuery.tsx';
|
2020-12-25 06:36:34 +03:30
|
|
|
|
|
|
|
|
interface IProps {
|
2024-07-03 23:15:50 +02:00
|
|
|
source: GetSourcesListQuery['sources']['nodes'][number];
|
2024-01-09 22:09:31 +01:00
|
|
|
showSourceRepo: boolean;
|
2020-12-25 06:36:34 +03:30
|
|
|
}
|
|
|
|
|
|
2023-10-28 00:32:02 +02:00
|
|
|
export const SourceCard: React.FC<IProps> = (props: IProps) => {
|
2023-03-23 13:59:32 +01:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
2024-08-30 21:32:21 +02:00
|
|
|
const isMobileWidth = MediaQuery.useIsMobileWidth();
|
|
|
|
|
|
2020-12-25 06:36:34 +03:30
|
|
|
const {
|
2024-01-09 22:09:31 +01:00
|
|
|
source: {
|
|
|
|
|
id,
|
|
|
|
|
name,
|
|
|
|
|
lang,
|
|
|
|
|
iconUrl,
|
|
|
|
|
supportsLatest,
|
|
|
|
|
isNsfw,
|
|
|
|
|
extension: { repo },
|
|
|
|
|
},
|
|
|
|
|
showSourceRepo,
|
2020-12-25 06:36:34 +03:30
|
|
|
} = props;
|
|
|
|
|
|
2024-09-29 15:19:06 +02:00
|
|
|
const isLocalSource = Number(id) === 0;
|
|
|
|
|
const sourceName = isLocalSource ? t('source.local_source.title') : name;
|
|
|
|
|
|
2020-12-25 06:36:34 +03:30
|
|
|
return (
|
2021-09-09 22:19:33 +04:30
|
|
|
<Card
|
2021-11-17 15:45:25 +03:30
|
|
|
sx={{
|
2024-08-30 21:32:21 +02:00
|
|
|
margin: 1,
|
2024-01-02 23:32:49 +01:00
|
|
|
marginTop: 0,
|
2021-11-17 15:45:25 +03:30
|
|
|
}}
|
2021-09-09 22:19:33 +04:30
|
|
|
>
|
2023-11-11 23:43:22 +01:00
|
|
|
<CardActionArea
|
|
|
|
|
component={Link}
|
|
|
|
|
to={`/sources/${id}`}
|
|
|
|
|
state={{ contentType: SourceContentType.POPULAR, clearCache: true }}
|
|
|
|
|
>
|
2022-11-26 13:51:56 +01:00
|
|
|
<CardContent
|
|
|
|
|
sx={{
|
|
|
|
|
display: 'flex',
|
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
|
alignItems: 'center',
|
2024-08-30 21:32:21 +02:00
|
|
|
padding: 1.5,
|
2022-11-26 13:51:56 +01:00
|
|
|
}}
|
|
|
|
|
>
|
2024-01-09 22:09:31 +01:00
|
|
|
<Box sx={{ display: 'flex', alignItems: 'center' }}>
|
2022-11-26 13:51:56 +01:00
|
|
|
<Avatar
|
|
|
|
|
variant="rounded"
|
2024-09-29 15:19:06 +02:00
|
|
|
alt={sourceName}
|
2022-11-26 13:51:56 +01:00
|
|
|
sx={{
|
|
|
|
|
width: 56,
|
|
|
|
|
height: 56,
|
|
|
|
|
flex: '0 0 auto',
|
2024-08-30 21:32:21 +02:00
|
|
|
mr: 1,
|
2024-03-08 00:24:01 +01:00
|
|
|
background: 'transparent',
|
2022-11-26 13:51:56 +01:00
|
|
|
}}
|
2024-03-08 00:24:01 +01:00
|
|
|
>
|
|
|
|
|
<SpinnerImage
|
|
|
|
|
spinnerStyle={{ small: true }}
|
|
|
|
|
imgStyle={{ objectFit: 'cover', width: '100%', height: '100%' }}
|
2024-09-29 15:19:06 +02:00
|
|
|
alt={sourceName}
|
2024-03-08 00:24:01 +01:00
|
|
|
src={requestManager.getValidImgUrlFor(iconUrl)}
|
|
|
|
|
/>
|
|
|
|
|
</Avatar>
|
2023-02-06 10:06:33 +01:00
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: 'flex',
|
|
|
|
|
flexDirection: 'column',
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-08-30 21:32:21 +02:00
|
|
|
<Typography variant="h6" component="h3">
|
2024-09-29 15:19:06 +02:00
|
|
|
{sourceName}
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography
|
|
|
|
|
variant="caption"
|
|
|
|
|
sx={{
|
|
|
|
|
display: 'block',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{translateExtensionLanguage(lang)}
|
|
|
|
|
{isNsfw && (
|
|
|
|
|
<Typography
|
|
|
|
|
variant="caption"
|
|
|
|
|
color="error"
|
|
|
|
|
sx={{
|
|
|
|
|
display: 'inline',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{' 18+'}
|
|
|
|
|
</Typography>
|
|
|
|
|
)}
|
|
|
|
|
{showSourceRepo && (
|
|
|
|
|
<Typography
|
|
|
|
|
variant="caption"
|
|
|
|
|
sx={{
|
|
|
|
|
display: 'block',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{repo}
|
|
|
|
|
</Typography>
|
|
|
|
|
)}
|
2021-09-19 17:11:29 +04:30
|
|
|
</Typography>
|
2022-11-26 13:51:56 +01:00
|
|
|
</Box>
|
2021-11-17 15:45:25 +03:30
|
|
|
</Box>
|
2024-08-30 21:32:21 +02:00
|
|
|
<Stack sx={{ flexDirection: 'row', gap: 1 }}>
|
|
|
|
|
{supportsLatest && (
|
|
|
|
|
<Button
|
|
|
|
|
variant="outlined"
|
|
|
|
|
component={Link}
|
|
|
|
|
to={`/sources/${id}`}
|
|
|
|
|
state={{ contentType: SourceContentType.LATEST, clearCache: true }}
|
|
|
|
|
>
|
|
|
|
|
{t('global.button.latest')}
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
{!isMobileWidth && (
|
2023-05-28 12:16:06 +02:00
|
|
|
<Button
|
|
|
|
|
variant="outlined"
|
|
|
|
|
component={Link}
|
2023-06-04 21:30:15 +02:00
|
|
|
to={`/sources/${id}`}
|
2023-11-11 23:43:22 +01:00
|
|
|
state={{ contentType: SourceContentType.POPULAR, clearCache: true }}
|
2023-05-28 12:16:06 +02:00
|
|
|
>
|
|
|
|
|
{t('global.button.popular')}
|
2021-09-09 20:43:13 +04:30
|
|
|
</Button>
|
2024-08-30 21:32:21 +02:00
|
|
|
)}
|
|
|
|
|
</Stack>
|
2022-11-26 13:51:56 +01:00
|
|
|
</CardContent>
|
|
|
|
|
</CardActionArea>
|
2020-12-25 06:36:34 +03:30
|
|
|
</Card>
|
|
|
|
|
);
|
2022-11-26 13:51:56 +01:00
|
|
|
};
|