import React from 'react' import classnames from 'classnames' import { ContentProps } from '../../types' import Message from '../../Message' import { ContentTree } from '@financial-times/content-tree' import ContentTreeFull = ContentTree.full interface FlourishProps extends ContentProps { iFrame?: boolean inArticleBody?: boolean } const Flourish: React.FC = ({ content: { id, flourishType, description, layoutWidth, fallbackImage, fragmentIdentifier, }, iFrame = false, inArticleBody = true, }) => { if (!id) return null const anchorHref = `#${id}` const fullGrid = layoutWidth === 'full-grid' const figureClassnames = classnames({ 'n-content-picture': true, 'n-content-layout__container': true, 'n-content-picture--wide': fullGrid, flourish__figure: iFrame, }) const iframeAspectRatio = iFrame && fallbackImage?.width && fallbackImage?.height ? `${fallbackImage.width}/${fallbackImage.height}` : '16/9' const imageAspectRatio = !inArticleBody && fallbackImage?.width && fallbackImage?.height ? { width: '100%', aspectRatio: `${fallbackImage.width}/${fallbackImage.height}`, } : {} return (
{iFrame && ( )}
{description}
) } export default Flourish