import React from 'react'; import classNames from 'classnames'; import { Localizer } from '../../types/Util'; import { AttachmentType } from './types'; interface Props { alt: string; attachment: AttachmentType; url: string; height?: number; width?: number; overlayText?: string; bottomOverlay?: boolean; closeButton?: boolean; curveBottomLeft?: boolean; curveBottomRight?: boolean; curveTopLeft?: boolean; curveTopRight?: boolean; smallCurveTopLeft?: boolean; darkOverlay?: boolean; playIconOverlay?: boolean; softCorners?: boolean; i18n: Localizer; onClick?: (attachment: AttachmentType) => void; onClickClose?: (attachment: AttachmentType) => void; onError?: () => void; } export class Image extends React.Component { // tslint:disable-next-line max-func-body-length cyclomatic-complexity public render() { const { alt, attachment, bottomOverlay, closeButton, curveBottomLeft, curveBottomRight, curveTopLeft, curveTopRight, darkOverlay, height, i18n, onClick, onClickClose, onError, overlayText, playIconOverlay, smallCurveTopLeft, softCorners, url, width, } = this.props; const { caption } = attachment || { caption: null }; return (
{ if (onClick) { onClick(attachment); } }} className={classNames( 'module-image', onClick ? 'module-image__with-click-handler' : null, curveBottomLeft ? 'module-image--curved-bottom-left' : null, curveBottomRight ? 'module-image--curved-bottom-right' : null, curveTopLeft ? 'module-image--curved-top-left' : null, curveTopRight ? 'module-image--curved-top-right' : null, smallCurveTopLeft ? 'module-image--small-curved-top-left' : null, softCorners ? 'module-image--soft-corners' : null )} > {alt} {caption ? ( {i18n('imageCaptionIconAlt')} ) : null}
{closeButton ? (
) => { e.stopPropagation(); if (onClickClose) { onClickClose(attachment); } }} className="module-image__close-button" /> ) : null} {bottomOverlay ? (
) : null} {playIconOverlay ? (
) : null} {overlayText ? (
{overlayText}
) : null}
); } }