/* * 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 { styled } from '@mui/material/styles'; import { useTranslation } from 'react-i18next'; import Button from '@mui/material/Button'; import Typography from '@mui/material/Typography'; import { MangaCardMode } from '@/modules/manga/MangaCard.types.tsx'; import { MediaQuery } from '@/lib/ui/MediaQuery.tsx'; import { useLibraryOptionsContext } from '@/components/context/LibraryOptionsContext.tsx'; const BadgeContainer = styled('div')(({ theme }) => ({ display: 'flex', height: 'fit-content', borderRadius: theme.shape.borderRadius, overflow: 'hidden', })); const Badge = styled(Typography)(({ theme }) => ({ color: theme.palette.primary.contrastText, paddingInline: theme.spacing(0.3), })); export const MangaBadges = ({ inLibraryIndicator, updateLibraryState, isInLibrary, unread, downloadCount, mode, }: { inLibraryIndicator?: boolean; updateLibraryState: () => void; isInLibrary: boolean; unread?: number; downloadCount?: number; mode: MangaCardMode; }) => { const { t } = useTranslation(); const isTouchDevice = MediaQuery.useIsTouchDevice(); const { options: { showUnreadBadge, showDownloadBadge }, } = useLibraryOptionsContext(); return ( {!isTouchDevice && inLibraryIndicator && mode === 'source' && ( )} {inLibraryIndicator && isInLibrary && ( {t('manga.button.in_library')} )} {((showUnreadBadge && mode === 'default') || mode === 'duplicate') && (unread ?? 0) > 0 && ( {unread} )} {((showDownloadBadge && mode === 'default') || mode === 'duplicate') && (downloadCount ?? 0) > 0 && ( {downloadCount} )} ); };