import * as React from "react"; import { TextHighlight, __experimentalVStack as VStack, __experimentalHStack as HStack, } from "@wordpress/components"; import { __ } from "@wordpress/i18n"; import type { Title, TitleIdType } from "../../types"; import { getIdMatch, getItemUrl } from "../../context/api"; import { TitleInfoContainer, TitleInfoHeader, Badge } from "./TitleInfo.styles"; export type TitleInfoProps = React.ComponentPropsWithoutRef & { as?: C; item: T; highlight?: string; idType?: TitleIdType; details?: boolean; }; export const TitleInfo = ({ as = "div" as C, highlight = "", idType: idTypeProp, details = false, item, ...props }: TitleInfoProps): JSX.Element => { highlight = String(highlight); const idMatch = getIdMatch(item as Title, highlight) || { id: null, idType: undefined }; const { id, idType: idMatchType } = idMatch; const idType = idTypeProp || idMatchType; const url = getItemUrl(item as Title, idType); const { objectType, title, director, originalReleaseYear } = item; const badgeSize = details ? "small" : "small"; return ( {title && } {objectType} {originalReleaseYear && ( )} {id && idType ? (
) : null}
{details && ( {director && ( {__('Director', 'justwatch-partner-integrations')}:{"\t"} )} )}
); };