import { AssetType } from '../types' import { ThemeScript } from './theme' import { GalleryItem, LightboxConfig, MetadataConfig, GroupByDateMode } from '../shared/types' import { ASSET_VERSION } from '../version' export type { GalleryItem, LightboxConfig, MetadataConfig, GroupByDateMode } export interface GalleryProps { items: GalleryItem[] title: string description: string publicBaseUrl: string path: string showDownloadZip: boolean showTitle: boolean // Formatted "available until" date shown in the subtitle, or undefined when // ipp.gallery.showExpiryDate is off or the share never expires. expiryDate?: string openItem?: number ogImageItem?: GalleryItem lightboxConfig: LightboxConfig metadataConfig: MetadataConfig groupByDate: GroupByDateMode | false metaBase?: string } export function Gallery (props: GalleryProps) { const initJson = JSON.stringify({ items: props.items, openItem: props.openItem, lightboxConfig: props.lightboxConfig, metadataConfig: props.metadataConfig, groupByDate: props.groupByDate, metaBase: props.metaBase }) const firstItem = props.items[0] // og:image prefers the album cover (passed via props); for videos, previewUrl // points to the .mp4, so use thumbnailUrl to keep og:image a still JPEG. const ogItem = props.ogImageItem || firstItem const ogImageAsset = ogItem ? (ogItem.type === AssetType.video ? ogItem.thumbnailUrl : ogItem.previewUrl) : '' const ogImageUrl = ogItem ? props.publicBaseUrl + ogImageAsset : '' // The title block also carries the subtitle (item count + optional expiry), // so it renders when a title is wanted OR there's an expiry date to show. const showHeaderText = props.showTitle || !!props.expiryDate return (
{props.items.length}{' '} {props.items.length === 1 ? 'item' : 'items'} {props.expiryDate && ( <>{' ยท available until '}{props.expiryDate}> )}
{props.description}
)} {/* Container is intentionally empty - web.js's virtualisation manager populates it with only the tiles within the viewport buffer. */} {props.showDownloadZip && (