From 163bda5de628a8e5508cb53898e51c822cc75dbf Mon Sep 17 00:00:00 2001 From: Vicente Canales Date: Tue, 23 Jan 2024 23:02:01 -0300 Subject: [PATCH] add shadow support to cover block --- .../block-library/src/cover/edit/index.js | 3 + packages/block-library/src/cover/save.js | 71 +++++++++++-------- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/packages/block-library/src/cover/edit/index.js b/packages/block-library/src/cover/edit/index.js index 8c5488584094c6..b3e67c4d4c55ff 100644 --- a/packages/block-library/src/cover/edit/index.js +++ b/packages/block-library/src/cover/edit/index.js @@ -17,6 +17,7 @@ import { useSettings, useInnerBlocksProps, __experimentalUseGradient, + __experimentalUseShadowProps as useShadowProps, store as blockEditorStore, } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; @@ -289,7 +290,9 @@ function CoverEdit( { const isImgElement = ! ( hasParallax || isRepeated ); + const shadowProps = useShadowProps( attributes ); const style = { + ...shadowProps.style, minHeight: minHeightWithUnit || undefined, }; diff --git a/packages/block-library/src/cover/save.js b/packages/block-library/src/cover/save.js index 680e92a5f9177b..4c4a300c91ed41 100644 --- a/packages/block-library/src/cover/save.js +++ b/packages/block-library/src/cover/save.js @@ -10,6 +10,7 @@ import { useInnerBlocksProps, getColorClassName, __experimentalGetGradientClass, + __experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles, useBlockProps, } from '@wordpress/block-editor'; @@ -61,7 +62,9 @@ export default function save( { attributes } ) { const isImgElement = ! ( hasParallax || isRepeated ); + const shadowProps = getShadowClassesAndStyles( attributes ); const style = { + ...shadowProps.style, minHeight: minHeight || undefined, }; @@ -124,42 +127,48 @@ export default function save( { attributes } ) { style={ bgStyle } /> - { ! useFeaturedImage && - isImageBackground && - url && - ( isImgElement ? ( - { + { ! useFeaturedImage && + isImageBackground && + url && + ( isImgElement ? ( + { + ) : ( +
+ ) ) } + { isVideoBackground && url && ( +