import { useCallback } from "react"; import { Chip } from "./Chip"; import { Img } from "./Img"; import { UpPressable } from "./Containers/UpPressable"; import { UploadImageFragment } from "graphql/generated"; import { ImageQuality } from "helpers/img"; import { TranslatedProps } from "types/TranslatedProps"; import { useSmartLanguage } from "hooks/useSmartLanguage"; import { cIf, cJoin } from "helpers/className"; import { isDefined } from "helpers/asserts"; /* * ╭─────────────╮ * ───────────────────────────────────────╯ COMPONENT ╰─────────────────────────────────────────── */ interface Props { thumbnail?: UploadImageFragment | string | null | undefined; href: string; pre_title?: string | null | undefined; title: string | null | undefined; subtitle?: string | null | undefined; topChips?: string[]; bottomChips?: string[]; disabled?: boolean; } // ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ export const PreviewLine = ({ href, thumbnail, pre_title, title, subtitle, topChips, disabled, bottomChips, }: Props): JSX.Element => ( {thumbnail && ( )} {topChips && topChips.length > 0 && ( {topChips.map((text, index) => ( ))} )} {pre_title && {pre_title}} {title && {title}} {subtitle && {subtitle}} {bottomChips && bottomChips.length > 0 && ( {bottomChips.map((text, index) => ( ))} )} ); /* * ╭──────────────────────╮ * ───────────────────────────────────╯ TRANSLATED VARIANT ╰────────────────────────────────────── */ export const TranslatedPreviewLine = ({ translations, fallback, ...otherProps }: TranslatedProps): JSX.Element => { const [selectedTranslation] = useSmartLanguage({ items: translations, languageExtractor: useCallback((item: { language: string }): string => item.language, []), }); return ( ); };
{pre_title}
{title}
{subtitle}