forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave.js
More file actions
29 lines (27 loc) · 744 Bytes
/
save.js
File metadata and controls
29 lines (27 loc) · 744 Bytes
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
/**
* WordPress dependencies
*/
import { useBlockProps, getSpacingPresetCssVar } from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import { DEFAULT_HEIGHT } from './constants';
export default function save( { attributes } ) {
const { height, width, style } = attributes;
const { layout: { selfStretch } = {} } = style || {};
// If selfStretch is set to 'fill' or 'fit', don't set default height.
const finalHeight =
selfStretch === 'fill' || selfStretch === 'fit' ? undefined : height;
return (
<div
{ ...useBlockProps.save( {
style: {
height:
getSpacingPresetCssVar( finalHeight ) || DEFAULT_HEIGHT,
width: getSpacingPresetCssVar( width ),
},
'aria-hidden': true,
} ) }
/>
);
}