'use client' import type React from 'react' import { Container, FadeInLift } from '@byline/ui/react' import cx from 'clsx' import { ResponsiveImage } from '@/ui/byline/components/responsive-image' import { LexicalRichText } from '@/ui/byline/components/richtext-lexical' import type { PopulatedPhotoBlockData } from '@/ui/byline/types/content' import type { Locale } from '@/ui/byline/types/i18n' interface Props { id: string block: PopulatedPhotoBlockData lng: Locale constrainedLayout?: boolean className?: string } export function PhotoBlock({ id, block, lng, className, constrainedLayout, }: Props): React.JSX.Element | null { const { photo, alt, caption, display } = block // Missing, unresolved, and cycle-suppressed relations have no document. const media = photo?.document?.fields if (media == null) return null const Comp = display === 'full_width' ? 'div' : Container const captionRoot = caption != null && !Array.isArray(caption) && typeof caption === 'object' ? caption.root : undefined const captionChildren = captionRoot != null && !Array.isArray(captionRoot) && typeof captionRoot === 'object' ? captionRoot.children : undefined return ( {captionChildren != null && (
)}
) }