/*
* 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 Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import Button from '@mui/material/Button';
import { useTranslation } from 'react-i18next';
import {
Box,
CardActionArea,
CardMedia,
Collapse,
Link,
Stack,
Tooltip,
Typography,
useMediaQuery,
useTheme,
} from '@mui/material';
import { useLayoutEffect, useRef, useState } from 'react';
import parseHtml from 'html-react-parser';
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
import { SpinnerImage } from '@/components/util/SpinnerImage.tsx';
import { TrackerManga } from '@/lib/data/Trackers.ts';
import { TypographyMaxLines } from '@/components/atoms/TypographyMaxLines.tsx';
const TrackerMangaCardTitle = ({ title, selected }: { title: string; selected: boolean }) => (
{title}
);
const TrackerMangaCardInfo = ({ title, value }: { title: string; value: string }) => (
{title}
{value}
);
const SUMMARY_COLLAPSED_SIZE = 50;
const TrackerMangaCardSummary = ({ summary }: { summary: string }) => {
const { t } = useTranslation();
const summaryRef = useRef(null);
const [isSummaryExpanded, setIsSummaryExpanded] = useState(false);
const [showSummaryExpandButton, setShowSummaryExpandButton] = useState(false);
const summaryCollapsedSize = showSummaryExpandButton ? SUMMARY_COLLAPSED_SIZE : 0;
useLayoutEffect(() => {
const shouldCollapseSummary = (summaryRef.current?.clientHeight ?? 0) > SUMMARY_COLLAPSED_SIZE;
setShowSummaryExpandButton(shouldCollapseSummary);
setIsSummaryExpanded(!shouldCollapseSummary);
}, []);
return (
<>
{summary.length && (
{parseHtml(summary)}
)}
{summary.length && showSummaryExpandButton && (
)}
>
);
};
const TrackerMangaCardLink = ({ children, url }: { children: React.ReactNode; url: string }) => (
e.stopPropagation()}
onMouseDown={(e) => e.stopPropagation()}
>
{children}
);
export const TrackerMangaCard = ({
manga,
selected,
onSelect,
}: {
manga: TrackerManga;
selected: boolean;
onSelect: () => void;
}) => {
const { t } = useTranslation();
const theme = useTheme();
const isMobileWidth = useMediaQuery(theme.breakpoints.down('sm'));
return (
);
};