mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
refactor: update titlecard to use StatusBadgeMini (#3205)
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import Spinner from '@app/assets/spinner.svg';
|
||||||
import { CheckCircleIcon } from '@heroicons/react/20/solid';
|
import { CheckCircleIcon } from '@heroicons/react/20/solid';
|
||||||
import { BellIcon, ClockIcon, MinusSmallIcon } from '@heroicons/react/24/solid';
|
import { BellIcon, ClockIcon, MinusSmallIcon } from '@heroicons/react/24/solid';
|
||||||
import { MediaStatus } from '@server/constants/media';
|
import { MediaStatus } from '@server/constants/media';
|
||||||
@@ -5,31 +6,40 @@ import { MediaStatus } from '@server/constants/media';
|
|||||||
interface StatusBadgeMiniProps {
|
interface StatusBadgeMiniProps {
|
||||||
status: MediaStatus;
|
status: MediaStatus;
|
||||||
is4k?: boolean;
|
is4k?: boolean;
|
||||||
|
inProgress?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StatusBadgeMini = ({ status, is4k = false }: StatusBadgeMiniProps) => {
|
const StatusBadgeMini = ({
|
||||||
const badgeStyle = ['w-5 rounded-full p-0.5 text-white ring-1'];
|
status,
|
||||||
|
is4k = false,
|
||||||
|
inProgress = false,
|
||||||
|
}: StatusBadgeMiniProps) => {
|
||||||
|
const badgeStyle = ['w-5 rounded-full p-0.5 ring-1 bg-opacity-80'];
|
||||||
let indicatorIcon: React.ReactNode;
|
let indicatorIcon: React.ReactNode;
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case MediaStatus.PROCESSING:
|
case MediaStatus.PROCESSING:
|
||||||
badgeStyle.push('bg-indigo-500 ring-indigo-400');
|
badgeStyle.push('bg-indigo-500 ring-indigo-400 text-indigo-100');
|
||||||
indicatorIcon = <ClockIcon />;
|
indicatorIcon = <ClockIcon />;
|
||||||
break;
|
break;
|
||||||
case MediaStatus.AVAILABLE:
|
case MediaStatus.AVAILABLE:
|
||||||
badgeStyle.push('bg-green-500 ring-green-400');
|
badgeStyle.push('bg-green-500 ring-green-400 text-green-100');
|
||||||
indicatorIcon = <CheckCircleIcon />;
|
indicatorIcon = <CheckCircleIcon />;
|
||||||
break;
|
break;
|
||||||
case MediaStatus.PENDING:
|
case MediaStatus.PENDING:
|
||||||
badgeStyle.push('bg-yellow-500 ring-yellow-400');
|
badgeStyle.push('bg-yellow-500 ring-yellow-400 text-yellow-100');
|
||||||
indicatorIcon = <BellIcon />;
|
indicatorIcon = <BellIcon />;
|
||||||
break;
|
break;
|
||||||
case MediaStatus.PARTIALLY_AVAILABLE:
|
case MediaStatus.PARTIALLY_AVAILABLE:
|
||||||
badgeStyle.push('bg-green-500 ring-green-400');
|
badgeStyle.push('bg-green-500 ring-green-400 text-green-100');
|
||||||
indicatorIcon = <MinusSmallIcon />;
|
indicatorIcon = <MinusSmallIcon />;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (inProgress) {
|
||||||
|
indicatorIcon = <Spinner />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="inline-flex whitespace-nowrap rounded-full text-xs font-semibold leading-5 ring-1 ring-gray-700">
|
<div className="inline-flex whitespace-nowrap rounded-full text-xs font-semibold leading-5 ring-1 ring-gray-700">
|
||||||
<div className={badgeStyle.join(' ')}>{indicatorIcon}</div>
|
<div className={badgeStyle.join(' ')}>{indicatorIcon}</div>
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import Spinner from '@app/assets/spinner.svg';
|
import Spinner from '@app/assets/spinner.svg';
|
||||||
import Button from '@app/components/Common/Button';
|
import Button from '@app/components/Common/Button';
|
||||||
import CachedImage from '@app/components/Common/CachedImage';
|
import CachedImage from '@app/components/Common/CachedImage';
|
||||||
|
import StatusBadgeMini from '@app/components/Common/StatusBadgeMini';
|
||||||
import RequestModal from '@app/components/RequestModal';
|
import RequestModal from '@app/components/RequestModal';
|
||||||
import ErrorCard from '@app/components/TitleCard/ErrorCard';
|
import ErrorCard from '@app/components/TitleCard/ErrorCard';
|
||||||
import Placeholder from '@app/components/TitleCard/Placeholder';
|
import Placeholder from '@app/components/TitleCard/Placeholder';
|
||||||
@@ -9,9 +10,7 @@ import { Permission, useUser } from '@app/hooks/useUser';
|
|||||||
import globalMessages from '@app/i18n/globalMessages';
|
import globalMessages from '@app/i18n/globalMessages';
|
||||||
import { withProperties } from '@app/utils/typeHelpers';
|
import { withProperties } from '@app/utils/typeHelpers';
|
||||||
import { Transition } from '@headlessui/react';
|
import { Transition } from '@headlessui/react';
|
||||||
import { CheckCircleIcon } from '@heroicons/react/20/solid';
|
|
||||||
import { ArrowDownTrayIcon } from '@heroicons/react/24/outline';
|
import { ArrowDownTrayIcon } from '@heroicons/react/24/outline';
|
||||||
import { BellIcon, ClockIcon } from '@heroicons/react/24/solid';
|
|
||||||
import { MediaStatus } from '@server/constants/media';
|
import { MediaStatus } from '@server/constants/media';
|
||||||
import type { MediaType } from '@server/models/Search';
|
import type { MediaType } from '@server/models/Search';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
@@ -142,28 +141,14 @@ const TitleCard = ({
|
|||||||
: intl.formatMessage(globalMessages.tvshow)}
|
: intl.formatMessage(globalMessages.tvshow)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="pointer-events-none z-40">
|
{currentStatus && (
|
||||||
{(currentStatus === MediaStatus.AVAILABLE ||
|
<div className="pointer-events-none z-40">
|
||||||
currentStatus === MediaStatus.PARTIALLY_AVAILABLE) && (
|
<StatusBadgeMini
|
||||||
<div className="flex h-4 w-4 items-center justify-center rounded-full border border-green-500 bg-green-500 bg-opacity-80 text-green-100 shadow sm:h-5 sm:w-5">
|
status={currentStatus}
|
||||||
<CheckCircleIcon className="h-3 w-3 sm:h-4 sm:w-4" />
|
inProgress={inProgress}
|
||||||
</div>
|
/>
|
||||||
)}
|
</div>
|
||||||
{currentStatus === MediaStatus.PENDING && (
|
)}
|
||||||
<div className="flex h-4 w-4 items-center justify-center rounded-full border border-yellow-500 bg-yellow-500 bg-opacity-80 text-yellow-100 shadow sm:h-5 sm:w-5">
|
|
||||||
<BellIcon className="h-3 w-3 sm:h-4 sm:w-4" />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{currentStatus === MediaStatus.PROCESSING && (
|
|
||||||
<div className="flex h-4 w-4 items-center justify-center rounded-full border border-indigo-500 bg-indigo-500 bg-opacity-80 text-indigo-100 shadow sm:h-5 sm:w-5">
|
|
||||||
{inProgress ? (
|
|
||||||
<Spinner className="h-3 w-3" />
|
|
||||||
) : (
|
|
||||||
<ClockIcon className="h-3 w-3 sm:h-4 sm:w-4" />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<Transition
|
<Transition
|
||||||
as={Fragment}
|
as={Fragment}
|
||||||
|
Reference in New Issue
Block a user