Product gallery/legacy/transform (#42719)
* Product Image Gallery: Add transform to Product Gallery block * Single Product Template: Transform to blocks with new Product Gallery block * Ensure we first check for block existance * Add changelog * Add/delete changelog file
This commit is contained in:
parent
81c19c0e39
commit
255f1ff919
|
@ -3,6 +3,8 @@
|
|||
*/
|
||||
import { gallery as icon } from '@wordpress/icons';
|
||||
import { registerBlockSingleProductTemplate } from '@woocommerce/atomic-utils';
|
||||
import { createBlock } from '@wordpress/blocks';
|
||||
import { isExperimentalBuild } from '@woocommerce/block-settings';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -11,6 +13,8 @@ import edit from './edit';
|
|||
import metadata from './block.json';
|
||||
import './style.scss';
|
||||
|
||||
const galleryBlock = isExperimentalBuild() ? 'woocommerce/product-gallery' : '';
|
||||
|
||||
registerBlockSingleProductTemplate( {
|
||||
blockName: metadata.name,
|
||||
// @ts-expect-error: `metadata` currently does not have a type definition in WordPress core
|
||||
|
@ -19,6 +23,17 @@ registerBlockSingleProductTemplate( {
|
|||
icon,
|
||||
// @ts-expect-error `edit` can be extended to include other attributes
|
||||
edit,
|
||||
transforms: {
|
||||
to: [
|
||||
{
|
||||
type: 'block',
|
||||
blocks: [ galleryBlock ],
|
||||
transform: () => {
|
||||
return createBlock( galleryBlock );
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
isAvailableOnPostEditor: false,
|
||||
} );
|
||||
|
|
|
@ -6,12 +6,17 @@ import { isWpVersion } from '@woocommerce/settings';
|
|||
import { BlockInstance, createBlock } from '@wordpress/blocks';
|
||||
import { VARIATION_NAME as PRODUCT_TITLE_VARIATION_NAME } from '@woocommerce/blocks/product-query/variations/elements/product-title';
|
||||
import { VARIATION_NAME as PRODUCT_SUMMARY_VARIATION_NAME } from '@woocommerce/blocks/product-query/variations/elements/product-summary';
|
||||
import { isExperimentalBuild } from '@woocommerce/block-settings';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { OnClickCallbackParameter } from './types';
|
||||
|
||||
const galleryBlock = isExperimentalBuild()
|
||||
? 'woocommerce/product-gallery'
|
||||
: 'woocommerce/product-image-gallery';
|
||||
|
||||
const getBlockifiedTemplate = () =>
|
||||
[
|
||||
createBlock( 'woocommerce/breadcrumbs' ),
|
||||
|
@ -29,7 +34,7 @@ const getBlockifiedTemplate = () =>
|
|||
justifyContent: 'right',
|
||||
width: '512px',
|
||||
},
|
||||
[ createBlock( 'woocommerce/product-image-gallery' ) ]
|
||||
[ createBlock( galleryBlock ) ]
|
||||
),
|
||||
createBlock( 'core/column', {}, [
|
||||
createBlock( 'core/post-title', {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
Significance: patch
|
||||
Type: tweak
|
||||
Comment: Product Gallery: Add transforms for better discovery.
|
Loading…
Reference in New Issue