'use client'; import { clsx } from 'clsx/lite'; import { Photo, PhotoDateRange, PhotoSetCategory, dateRangeForPhotos, titleForPhoto, } from '.'; import ShareButton from '@/share/ShareButton'; import AnimateItems from '@/components/AnimateItems'; import { ReactNode } from 'react'; import DivDebugBaselineGrid from '@/components/DivDebugBaselineGrid'; import PhotoPrevNext from './PhotoPrevNext'; import PhotoLink from './PhotoLink'; import ResponsiveText from '@/components/primitives/ResponsiveText'; import { useAppState } from '@/state/AppState'; export default function PhotoHeader({ tag, camera, simulation, focal, photos, selectedPhoto, entity, entityVerb = 'PHOTO', entityDescription, indexNumber, count, dateRange, includeShareButton, }: { photos: Photo[] selectedPhoto?: Photo entity?: ReactNode entityVerb?: string entityDescription?: string indexNumber?: number count?: number dateRange?: PhotoDateRange includeShareButton?: boolean } & PhotoSetCategory) { const { isGridHighDensity } = useAppState(); const { start, end } = dateRangeForPhotos(photos, dateRange); const selectedPhotoIndex = selectedPhoto ? photos.findIndex(photo => photo.id === selectedPhoto.id) : undefined; const paginationLabel = (indexNumber || (selectedPhotoIndex ?? 0 + 1)) + ' of ' + (count ?? photos.length); const headerType = selectedPhotoIndex === undefined ? 'photo-set' : entity ? 'photo-detail-with-entity' : 'photo-detail'; const renderPrevNext = () => ; const renderDateRange = () => {start === end ? start : <>{end}
– {start}}
; const renderContentA = () => entity ?? ( selectedPhoto !== undefined && {titleForPhoto(selectedPhoto, true)} ); return ( {/* Content A: Filter Set or Photo Title */}
{headerType === 'photo-detail-with-entity' ? renderContentA() // Necessary for title truncation :

{renderContentA()}

}
{/* Content B: Filter Set Meta or Photo Pagination */}
{entity && <> {headerType === 'photo-set' ? <> {entityDescription} {includeShareButton && } : {entityVerb} {paginationLabel} } }
{/* Content C: Nav */}
{selectedPhoto ? renderPrevNext() : renderDateRange()}
, ]} /> ); }