File size: 1,357 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { Button } from '@automattic/components';
import { useResizeObserver } from '@wordpress/compose';
import { Icon, copy } from '@wordpress/icons';
import clsx from 'clsx';
import { useTranslate } from 'i18n-calypso';

import './style.scss';

type PatternPreviewPlaceholderProps = {
	className?: string;
	title?: string;
};

export function PatternPreviewPlaceholder( { className, title }: PatternPreviewPlaceholderProps ) {
	const translate = useTranslate();
	const [ resizeObserver, nodeSize ] = useResizeObserver();

	const isPreviewLarge = nodeSize?.width ? nodeSize.width > 960 : true;

	const copyButtonText = isPreviewLarge
		? translate( 'Copy pattern', {
				comment: 'Button label for copying a pattern',
				textOnly: true,
		  } )
		: translate( 'Copy', {
				comment: 'Button label for copying a pattern',
				textOnly: true,
		  } );

	return (
		<div
			className={ clsx( 'pattern-preview is-loading', className, {
				'is-server': typeof window !== 'undefined',
			} ) }
		>
			{ resizeObserver }

			<div className="pattern-preview__renderer" />

			<div className="pattern-preview__header">
				<div className="pattern-preview__title">{ title }</div>

				<Button className="pattern-preview__copy is-placeholder" primary>
					<Icon height={ 18 } icon={ copy } width={ 18 } /> { copyButtonText }
				</Button>
			</div>
		</div>
	);
}