import { AssetType, jsonForInlineScript, ThemeScript } from '@ipp/core' 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 = jsonForInlineScript({ 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.title} {props.description && <> } {firstItem && <> } {(showHeaderText || props.showDownloadZip) && ( )} {props.description && (

{props.description}

)} {/* Container is intentionally empty - web.js's virtualisation manager populates it with only the tiles within the viewport buffer. */} {props.showDownloadZip && ( )} {/* Init params for web.js (read at module load). Using a JSON script block avoids the cross-script-type coordination problems that come with mixing classic and module scripts. */} ) }