Back

100% Statements 2/2
72.72% Branches 8/11
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                    2x             1x                                                                
import { __ } from '@wordpress/i18n';
import { baseDomain } from '../helpers';
import { MediaImage } from '../shared/media-image';
import { tumblrTitle } from './helpers';
import TumblrPostActions from './post/actions';
import TumblrPostHeader from './post/header';
import type { TumblrPreviewProps } from './types';
 
import './styles.scss';
 
export const TumblrLinkPreview: React.FC< TumblrPreviewProps > = ( {
	title,
	image,
	user,
	url,
	imageFocalPoint,
} ) => {
	return (
		<div className="tumblr-preview__post">
			<div className="tumblr-preview__card">
				<TumblrPostHeader user={ user } />
				<div className="tumblr-preview__window">
					{ image && (
						<div className="tumblr-preview__window-top">
							<MediaImage
								className="tumblr-preview__image"
								src={ image }
								alt={ __( 'Tumblr preview thumbnail', 'social-previews' ) }
								focalPoint={ imageFocalPoint }
							/>
							{ title && (
								<div className="tumblr-preview__overlay">
									<div className="tumblr-preview__overlay-title">{ tumblrTitle( title ) }</div>
								</div>
							) }
						</div>
					) }
					<div className={ `tumblr-preview__window-bottom ${ ! image ? 'is-full' : '' }` }>
						{ ! image && title && (
							<div className="tumblr-preview__window-title">{ tumblrTitle( title ) }</div>
						) }
						{ url && <div className="tumblr-preview__site-name">{ baseDomain( url ) }</div> }
					</div>
				</div>
				<TumblrPostActions />
			</div>
		</div>
	);
};