mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Convert mediainfo PrimaryMediaInfo to react
This commit is contained in:
parent
2e90f669e5
commit
c3b5d50313
8 changed files with 766 additions and 0 deletions
103
src/components/mediainfo/PrimaryMediaInfo.tsx
Normal file
103
src/components/mediainfo/PrimaryMediaInfo.tsx
Normal file
|
@ -0,0 +1,103 @@
|
|||
import React, { FC } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import Box from '@mui/material/Box';
|
||||
import usePrimaryMediaInfo from './usePrimaryMediaInfo';
|
||||
|
||||
import MediaInfoItem from './MediaInfoItem';
|
||||
import StarIcons from './StarIcons';
|
||||
import CaptionMediaInfo from './CaptionMediaInfo';
|
||||
import CriticRatingMediaInfo from './CriticRatingMediaInfo';
|
||||
import EndsAt from './EndsAt';
|
||||
import type { ItemDto } from 'types/itemDto';
|
||||
import type { MiscInfo } from 'types/mediaInfoItem';
|
||||
|
||||
interface PrimaryMediaInfoProps {
|
||||
className?: string;
|
||||
item: ItemDto;
|
||||
isYearEnabled?: boolean;
|
||||
isContainerEnabled?: boolean;
|
||||
isEpisodeTitleEnabled?: boolean;
|
||||
isCriticRatingEnabled?: boolean;
|
||||
isEndsAtEnabled?: boolean;
|
||||
isOriginalAirDateEnabled?: boolean;
|
||||
isRuntimeEnabled?: boolean;
|
||||
isProgramIndicatorEnabled?: boolean;
|
||||
isEpisodeTitleIndexNumberEnabled?: boolean;
|
||||
isOfficialRatingEnabled?: boolean;
|
||||
isStarRatingEnabled?: boolean;
|
||||
isCaptionIndicatorEnabled?: boolean;
|
||||
isMissingIndicatorEnabled?: boolean;
|
||||
getMissingIndicator: () => React.JSX.Element | null
|
||||
}
|
||||
|
||||
const PrimaryMediaInfo: FC<PrimaryMediaInfoProps> = ({
|
||||
className,
|
||||
item,
|
||||
isYearEnabled = false,
|
||||
isContainerEnabled = false,
|
||||
isEpisodeTitleEnabled = false,
|
||||
isCriticRatingEnabled = false,
|
||||
isEndsAtEnabled = false,
|
||||
isOriginalAirDateEnabled = false,
|
||||
isRuntimeEnabled = false,
|
||||
isProgramIndicatorEnabled = false,
|
||||
isEpisodeTitleIndexNumberEnabled = false,
|
||||
isOfficialRatingEnabled = false,
|
||||
isStarRatingEnabled = false,
|
||||
isCaptionIndicatorEnabled = false,
|
||||
isMissingIndicatorEnabled = false,
|
||||
getMissingIndicator
|
||||
}) => {
|
||||
const miscInfo = usePrimaryMediaInfo({
|
||||
item,
|
||||
isYearEnabled,
|
||||
isContainerEnabled,
|
||||
isEpisodeTitleEnabled,
|
||||
isOriginalAirDateEnabled,
|
||||
isRuntimeEnabled,
|
||||
isProgramIndicatorEnabled,
|
||||
isEpisodeTitleIndexNumberEnabled,
|
||||
isOfficialRatingEnabled
|
||||
});
|
||||
const {
|
||||
StartDate,
|
||||
HasSubtitles,
|
||||
MediaType,
|
||||
RunTimeTicks,
|
||||
CommunityRating,
|
||||
CriticRating
|
||||
} = item;
|
||||
|
||||
const cssClass = classNames(className);
|
||||
|
||||
const renderMediaInfo = (info: MiscInfo | undefined, index: number) => (
|
||||
<MediaInfoItem key={index} miscInfo={info} />
|
||||
);
|
||||
|
||||
return (
|
||||
<Box className={cssClass}>
|
||||
{miscInfo.map((info, index) => renderMediaInfo(info, index))}
|
||||
|
||||
{isStarRatingEnabled && CommunityRating && (
|
||||
<StarIcons communityRating={CommunityRating} />
|
||||
)}
|
||||
|
||||
{HasSubtitles && isCaptionIndicatorEnabled && <CaptionMediaInfo />}
|
||||
|
||||
{CriticRating && isCriticRatingEnabled && (
|
||||
<CriticRatingMediaInfo criticRating={CriticRating} />
|
||||
)}
|
||||
|
||||
{isEndsAtEnabled
|
||||
&& MediaType === 'Video'
|
||||
&& RunTimeTicks
|
||||
&& !StartDate && <EndsAt runTimeTicks={RunTimeTicks} />}
|
||||
|
||||
{isMissingIndicatorEnabled && (
|
||||
getMissingIndicator()
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default PrimaryMediaInfo;
|
Loading…
Add table
Add a link
Reference in a new issue