Files
suwayomi-material-you-webui/src/modules/manga/components/ContinueReadingButton.tsx
T

53 lines
1.8 KiB
TypeScript
Raw Normal View History

2023-12-19 15:17:00 +01:00
/*
* 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 { useTranslation } from 'react-i18next';
2024-04-14 15:50:12 +02:00
import Button from '@mui/material/Button';
2023-12-19 15:17:00 +01:00
import PlayArrowIcon from '@mui/icons-material/PlayArrow';
import { Link } from 'react-router-dom';
2025-02-01 14:24:38 +01:00
import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx';
import { Chapters } from '@/modules/chapter/services/Chapters.ts';
import { MUIUtil } from '@/lib/mui/MUI.util.ts';
import { ChapterReadInfo, ChapterSourceOrderInfo } from '@/modules/chapter/Chapter.types.ts';
2023-12-19 15:17:00 +01:00
export const ContinueReadingButton = ({
showContinueReadingButton,
2024-12-06 23:59:39 +01:00
chapter,
2023-12-19 15:17:00 +01:00
mangaLinkTo,
}: {
showContinueReadingButton: boolean;
2024-12-06 23:59:39 +01:00
chapter?: (ChapterSourceOrderInfo & ChapterReadInfo) | null;
2023-12-19 15:17:00 +01:00
mangaLinkTo: string;
}) => {
const { t } = useTranslation();
2024-12-06 23:59:39 +01:00
if (!showContinueReadingButton || !chapter) {
2023-12-19 15:17:00 +01:00
return null;
}
2024-12-06 23:59:39 +01:00
const { sourceOrder } = chapter;
const isFirstChapter = sourceOrder === 1;
2023-12-19 15:17:00 +01:00
return (
2025-02-01 14:24:38 +01:00
<CustomTooltip title={t(isFirstChapter ? 'global.button.start' : 'global.button.resume')}>
2023-12-19 15:17:00 +01:00
<Button
{...MUIUtil.preventRippleProp()}
2023-12-19 15:17:00 +01:00
variant="contained"
size="small"
2024-08-30 21:19:40 +02:00
sx={{ minWidth: 'unset', py: 0.5, px: 0.75 }}
component={Link}
2024-12-11 20:10:59 +01:00
to={`${mangaLinkTo}/chapter/${chapter.sourceOrder}`}
state={Chapters.getReaderOpenChapterLocationState(chapter)}
2023-12-19 15:17:00 +01:00
onClick={(e) => e.stopPropagation()}
>
<PlayArrowIcon />
</Button>
2025-02-01 14:24:38 +01:00
</CustomTooltip>
2023-12-19 15:17:00 +01:00
);
};