diff --git a/assets/js/blocks/product-gallery/edit.tsx b/assets/js/blocks/product-gallery/edit.tsx index 32734ff9e82..e337ebc10cb 100644 --- a/assets/js/blocks/product-gallery/edit.tsx +++ b/assets/js/blocks/product-gallery/edit.tsx @@ -17,6 +17,7 @@ import { useSelect } from '@wordpress/data'; import { moveInnerBlocksToPosition, getInnerBlocksLockAttributes, + getClassNameByNextPreviousButtonsPosition, } from './utils'; import { ProductGalleryThumbnailsBlockSettings } from './inner-blocks/product-gallery-thumbnails/block-settings'; import { ProductGalleryPagerBlockSettings } from './inner-blocks/product-gallery-pager/settings'; @@ -107,7 +108,11 @@ export const Edit = ( { attributes, setAttributes, }: BlockEditProps< ProductGalleryAttributes > ) => { - const blockProps = useBlockProps(); + const blockProps = useBlockProps( { + className: getClassNameByNextPreviousButtonsPosition( + attributes.nextPreviousButtonsPosition + ), + } ); const { currentTemplateId, templateType } = useSelect( ( select ) => ( { diff --git a/assets/js/blocks/product-gallery/editor.scss b/assets/js/blocks/product-gallery/editor.scss index 001a7de19df..13116d7fc2d 100644 --- a/assets/js/blocks/product-gallery/editor.scss +++ b/assets/js/blocks/product-gallery/editor.scss @@ -1,4 +1,4 @@ -.wp-block-woocommerce-product-gallery { +.wc-block-product-gallery { .block-editor-inner-blocks { width: fit-content; } diff --git a/assets/js/blocks/product-gallery/index.tsx b/assets/js/blocks/product-gallery/index.tsx index f16ed90edb2..5fb28bd3ad8 100644 --- a/assets/js/blocks/product-gallery/index.tsx +++ b/assets/js/blocks/product-gallery/index.tsx @@ -12,6 +12,7 @@ import { Save } from './save'; import metadata from './block.json'; import icon from './icon'; import './style.scss'; +import './inner-blocks/product-gallery-large-image'; import './inner-blocks/product-gallery-large-image-next-previous'; import './inner-blocks/product-gallery-pager'; import './inner-blocks/product-gallery-thumbnails'; diff --git a/assets/js/blocks/product-gallery/inner-blocks/product-gallery-large-image-next-previous/edit.tsx b/assets/js/blocks/product-gallery/inner-blocks/product-gallery-large-image-next-previous/edit.tsx index b2ab03c08cc..db146df1f4f 100644 --- a/assets/js/blocks/product-gallery/inner-blocks/product-gallery-large-image-next-previous/edit.tsx +++ b/assets/js/blocks/product-gallery/inner-blocks/product-gallery-large-image-next-previous/edit.tsx @@ -9,10 +9,11 @@ import classNames from 'classnames'; /** * Internal dependencies */ -import { NextButton, PrevButton } from './icons'; + import './editor.scss'; import { ProductGalleryNextPreviousBlockSettings } from './settings'; import { ProductGalleryContext } from '../../types'; +import { getNextPreviousImagesWithClassName } from './utils'; const getAlignmentStyle = ( alignment: string ): string => { switch ( alignment ) { @@ -41,19 +42,16 @@ export const Edit = ( { attributes.layout?.verticalAlignment ), }, + className: classNames( + 'wc-block-editor-product-gallery-large-image-next-previous', + 'wc-block-product-gallery-large-image-next-previous' + ), } ); - const suffixClass = useMemo( () => { - switch ( context.nextPreviousButtonsPosition ) { - case 'insideTheImage': - return 'inside-image'; - case 'outsideTheImage': - return 'outside-image'; - case 'off': - return 'off'; - default: - return 'off'; - } + const previousNextImage = useMemo( () => { + return getNextPreviousImagesWithClassName( + context.nextPreviousButtonsPosition + ); }, [ context.nextPreviousButtonsPosition ] ); return ( @@ -64,11 +62,15 @@ export const Edit = ( {