import React from 'react' import type { TopperFragment } from '@financial-times/cp-content-pipeline-client' import { AliasedBreakpoints, BreakpointGetter, Sources, } from '../content-tree/ImageSet' import { PictureOverrideWrapper } from '../ImageOverrideWrappers' import { ContentTree } from '@financial-times/content-tree' const topperGetBreakpointsMap: Partial< Record > = { SplitTextTopper(image) { switch (image.format) { case 'square': return [{ maxWidth: 490 }, { minWidth: 740, maxWidth: 1220 }] case 'standard': return { minWidth: 491, maxWidth: 739 } case 'wide': return { normal: { minWidth: 1221, maxWidth: 1440 }, widest: { minWidth: 1441 }, } } }, FullBleedTopper(image) { switch (image.format) { case 'square': return { maxWidth: 490 } case 'standard': return { minWidth: 491, maxWidth: 1219 } case 'wide': return { normal: { minWidth: 1220, maxWidth: 1439 }, wide: { minWidth: 1440, maxWidth: 1919 }, wideL: { minWidth: 1920 }, } } }, DeepPortraitTopper(image) { switch (image.format) { case 'portrait': return { small: { maxWidth: 490 }, normal: { minWidth: 491, maxWidth: 1440 }, wide: { minWidth: 1441 }, } } }, DeepLandscapeTopper(image): AliasedBreakpoints | undefined { switch (image.format) { case 'portrait': return { small: { maxWidth: 490 }, tablets: { minWidth: 491, maxWidth: 980 }, } case 'landscape': return { normal: { minWidth: 981, maxWidth: 1440 }, wide: { minWidth: 1441 }, } } }, } export type PictureProps = { topper: TopperFragment alt?: string } const Picture: React.FC = (props) => { const { topper, alt = '' } = props if (!('images' in topper) || !topper.fallbackImage) { return null } return (
{alt} {topper.fallbackImage.caption || topper.__typename === 'DeepPortraitTopper' || topper.__typename === 'DeepLandscapeTopper' ? (
{topper.fallbackImage.caption} {topper.fallbackImage.credit}
) : ( topper.fallbackImage.credit && (
{topper.fallbackImage.credit}
) )}
) } export default Picture