diff --git a/plugins/woocommerce-blocks/assets/css/editor.scss b/plugins/woocommerce-blocks/assets/css/editor.scss index 55a18b8b713..e187b37bd6a 100644 --- a/plugins/woocommerce-blocks/assets/css/editor.scss +++ b/plugins/woocommerce-blocks/assets/css/editor.scss @@ -19,29 +19,31 @@ flex-wrap: wrap; justify-content: flex-start; + &.components-placeholder { + padding: 2em 1em; + } + &.is-loading, - &.is-not-found, - &.cols-1 { + &.is-not-found { display: block; } - .wc-product-preview { - flex: 1; - padding: $gap/2; + &.cols-1 { + display: block; + + .wc-product-preview { + margin-left: auto; + margin-right: auto; + } } @for $i from 2 to 7 { &.cols-#{$i} .wc-product-preview { - max-width: calc(#{ 100% / $i }); - min-width: calc(#{ 100% / $i }); - flex: 1; + flex: 1 0 calc(#{ 100% / $i }); + max-width: 100% / $i !important; } } - &.components-placeholder { - padding: 2em 1em; - } - // Styles for "resuable block" preview. .editor-block-preview & { min-width: 5em; diff --git a/plugins/woocommerce-blocks/assets/js/components/product-preview/index.js b/plugins/woocommerce-blocks/assets/js/components/product-preview/index.js index 3fa5c930b44..38f84a627e7 100644 --- a/plugins/woocommerce-blocks/assets/js/components/product-preview/index.js +++ b/plugins/woocommerce-blocks/assets/js/components/product-preview/index.js @@ -13,13 +13,29 @@ import './style.scss'; * Display a preview for a given product. */ const ProductPreview = ( { product } ) => { - const { placeholderImgSrc } = wc_product_block_data; /* eslint-disable-line camelcase */ + const { + placeholderImgSrc, + } = wc_product_block_data; /* eslint-disable-line camelcase */ let image = null; if ( product.images.length ) { - image = ; + image = ( + + ); } else { - image = ; + image = ( + + ); } const rating = Number( product.average_rating ); @@ -29,7 +45,10 @@ const ProductPreview = ( { product } ) => { } return ( -
+
{ image }
wc_get_theme_support( 'product_blocks::min_rows', 1 ), 'max_rows' => wc_get_theme_support( 'product_blocks::max_rows', 6 ), 'default_rows' => wc_get_theme_support( 'product_blocks::default_rows', 1 ), + 'thumbnail_size' => wc_get_theme_support( 'thumbnail_image_width', 300 ), 'placeholderImgSrc' => wc_placeholder_img_src(), 'min_height' => wc_get_theme_support( 'featured_block::min_height', 500 ), 'default_height' => wc_get_theme_support( 'featured_block::default_height', 500 ), diff --git a/plugins/woocommerce-blocks/tests/js/setup-globals.js b/plugins/woocommerce-blocks/tests/js/setup-globals.js index e56e6f151eb..2dfd12c27a3 100644 --- a/plugins/woocommerce-blocks/tests/js/setup-globals.js +++ b/plugins/woocommerce-blocks/tests/js/setup-globals.js @@ -4,6 +4,7 @@ global.wp = {}; // Set up our settings global. global.wc_product_block_data = { placeholderImgSrc: 'placeholder.png', + thumbnail_size: '300', }; // wcSettings is required by @woocommerce/* packages