Remove placeholder and pagination (https://github.com/woocommerce/woocommerce-blocks/pull/11145)
* Add titles to patterns and set the aligment to Wide * Replace product query patterns with product collection ones * Remove pagination and no results query from product query patterns * Add aspect ratio to the product image attributes * Add portrait aspect ratio to product X column and product gallery patterns
This commit is contained in:
parent
b4f07b7c5f
commit
37623be4f2
|
@ -47,6 +47,9 @@ export const blockAttributes: BlockAttributes = {
|
|||
type: 'string',
|
||||
default: 'cover',
|
||||
},
|
||||
aspectRatio: {
|
||||
type: 'string',
|
||||
},
|
||||
};
|
||||
|
||||
export default blockAttributes;
|
||||
|
|
|
@ -49,6 +49,7 @@ interface ImageProps {
|
|||
scale: string;
|
||||
width?: string | undefined;
|
||||
height?: string | undefined;
|
||||
aspectRatio: string | undefined;
|
||||
}
|
||||
|
||||
const Image = ( {
|
||||
|
@ -59,6 +60,7 @@ const Image = ( {
|
|||
width,
|
||||
scale,
|
||||
height,
|
||||
aspectRatio,
|
||||
}: ImageProps ): JSX.Element => {
|
||||
const { thumbnail, src, srcset, sizes, alt } = image || {};
|
||||
const imageProps = {
|
||||
|
@ -72,6 +74,7 @@ const Image = ( {
|
|||
height,
|
||||
width,
|
||||
objectFit: scale,
|
||||
aspectRatio,
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -101,6 +104,7 @@ export const Block = ( props: Props ): JSX.Element | null => {
|
|||
height,
|
||||
width,
|
||||
scale,
|
||||
aspectRatio,
|
||||
...restProps
|
||||
} = props;
|
||||
const styleProps = useStyleProps( props );
|
||||
|
@ -171,6 +175,7 @@ export const Block = ( props: Props ): JSX.Element | null => {
|
|||
width={ width }
|
||||
height={ height }
|
||||
scale={ scale }
|
||||
aspectRatio={ aspectRatio }
|
||||
/>
|
||||
</ParentComponent>
|
||||
</div>
|
||||
|
|
|
@ -24,4 +24,6 @@ export interface BlockAttributes {
|
|||
width?: string;
|
||||
// Image scaling method.
|
||||
scale: 'cover' | 'contain' | 'fill';
|
||||
// Aspect ratio of the image.
|
||||
aspectRatio: string;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ $content = PatternsHelper::get_pattern_content( 'woocommerce-blocks/product-coll
|
|||
<!-- wp:woocommerce/product-collection {"query":{"perPage":3,"pages":0,"offset":0,"postType":"product","order":"asc","orderBy":"title","author":"","search":"","exclude":[],"sticky":"","inherit":false,"taxQuery":{},"parents":[],"isProductCollectionBlock":true,"woocommerceOnSale":false,"woocommerceStockStatus":["instock","outofstock","onbackorder"],"woocommerceAttributes":[],"woocommerceHandPickedProducts":[]},"tagName":"div","displayLayout":{"type":"flex","columns":3},"align":"wide"} -->
|
||||
<div class="wp-block-woocommerce-product-collection alignwide">
|
||||
<!-- wp:woocommerce/product-template -->
|
||||
<!-- wp:woocommerce/product-image {"imageSizing":"thumbnail","isDescendentOfQueryLoop":true} /-->
|
||||
<!-- wp:woocommerce/product-image {"aspectRatio":"3/5","imageSizing":"thumbnail","isDescendentOfQueryLoop":true} /-->
|
||||
|
||||
<!-- wp:woocommerce/product-rating {"isDescendentOfQueryLoop":true,"textAlign":"center"} /-->
|
||||
|
||||
|
@ -26,20 +26,6 @@ $content = PatternsHelper::get_pattern_content( 'woocommerce-blocks/product-coll
|
|||
|
||||
<!-- wp:woocommerce/product-price {"isDescendentOfQueryLoop":true,"textAlign":"center","fontSize":"small"} /-->
|
||||
<!-- /wp:woocommerce/product-template -->
|
||||
|
||||
<!-- wp:query-pagination {"layout":{"type":"flex","justifyContent":"center"}} -->
|
||||
<!-- wp:query-pagination-previous /-->
|
||||
|
||||
<!-- wp:query-pagination-numbers /-->
|
||||
|
||||
<!-- wp:query-pagination-next /-->
|
||||
<!-- /wp:query-pagination -->
|
||||
|
||||
<!-- wp:query-no-results -->
|
||||
<!-- wp:paragraph {"placeholder":"Add text or blocks that will display when a query returns no results."} -->
|
||||
<p></p>
|
||||
<!-- /wp:paragraph -->
|
||||
<!-- /wp:query-no-results -->
|
||||
</div>
|
||||
<!-- /wp:woocommerce/product-collection -->
|
||||
</div>
|
||||
|
|
|
@ -18,7 +18,7 @@ $content = PatternsHelper::get_pattern_content( 'woocommerce-blocks/product-coll
|
|||
<!-- wp:woocommerce/product-collection {"query":{"perPage":4,"pages":0,"offset":0,"postType":"product","order":"asc","orderBy":"title","author":"","search":"","exclude":[],"sticky":"","inherit":false,"taxQuery":{},"parents":[],"isProductCollectionBlock":true,"woocommerceOnSale":false,"woocommerceStockStatus":["instock","outofstock","onbackorder"],"woocommerceAttributes":[],"woocommerceHandPickedProducts":[]},"tagName":"div","displayLayout":{"type":"flex","columns":4},"align":"wide"} -->
|
||||
<div class="wp-block-woocommerce-product-collection alignwide">
|
||||
<!-- wp:woocommerce/product-template -->
|
||||
<!-- wp:woocommerce/product-image {"imageSizing":"thumbnail","isDescendentOfQueryLoop":true} /-->
|
||||
<!-- wp:woocommerce/product-image {"aspectRatio":"3/5","imageSizing":"thumbnail","isDescendentOfQueryLoop":true} /-->
|
||||
|
||||
<!-- wp:post-title {"textAlign":"center","level":3,"isLink":true,"style":{"spacing":{"margin":{"bottom":"0.75rem","top":"0"}}},"fontSize":"medium","__woocommerceNamespace":"woocommerce/product-collection/product-title"} /-->
|
||||
|
||||
|
@ -26,20 +26,6 @@ $content = PatternsHelper::get_pattern_content( 'woocommerce-blocks/product-coll
|
|||
|
||||
<!-- wp:woocommerce/product-button {"textAlign":"center","isDescendentOfQueryLoop":true,"fontSize":"small"} /-->
|
||||
<!-- /wp:woocommerce/product-template -->
|
||||
|
||||
<!-- wp:query-pagination {"layout":{"type":"flex","justifyContent":"center"}} -->
|
||||
<!-- wp:query-pagination-previous /-->
|
||||
|
||||
<!-- wp:query-pagination-numbers /-->
|
||||
|
||||
<!-- wp:query-pagination-next /-->
|
||||
<!-- /wp:query-pagination -->
|
||||
|
||||
<!-- wp:query-no-results -->
|
||||
<!-- wp:paragraph {"placeholder":"Add text or blocks that will display when a query returns no results."} -->
|
||||
<p></p>
|
||||
<!-- /wp:paragraph -->
|
||||
<!-- /wp:query-no-results -->
|
||||
</div>
|
||||
<!-- /wp:woocommerce/product-collection -->
|
||||
</div>
|
||||
|
|
|
@ -18,7 +18,7 @@ $content = PatternsHelper::get_pattern_content( 'woocommerce-blocks/product-coll
|
|||
<!-- wp:woocommerce/product-collection {"query":{"perPage":5,"pages":0,"offset":0,"postType":"product","order":"asc","orderBy":"title","author":"","search":"","exclude":[],"sticky":"","inherit":false,"taxQuery":{},"parents":[],"isProductCollectionBlock":true,"woocommerceOnSale":false,"woocommerceStockStatus":["instock","outofstock","onbackorder"],"woocommerceAttributes":[],"woocommerceHandPickedProducts":[]},"tagName":"div","displayLayout":{"type":"flex","columns":5},"align":"wide"} -->
|
||||
<div class="wp-block-woocommerce-product-collection alignwide">
|
||||
<!-- wp:woocommerce/product-template -->
|
||||
<!-- wp:woocommerce/product-image {"imageSizing":"thumbnail","isDescendentOfQueryLoop":true} /-->
|
||||
<!-- wp:woocommerce/product-image {"aspectRatio":"3/5","imageSizing":"thumbnail","isDescendentOfQueryLoop":true} /-->
|
||||
|
||||
<!-- wp:columns -->
|
||||
<div class="wp-block-columns">
|
||||
|
@ -36,20 +36,6 @@ $content = PatternsHelper::get_pattern_content( 'woocommerce-blocks/product-coll
|
|||
</div>
|
||||
<!-- /wp:columns -->
|
||||
<!-- /wp:woocommerce/product-template -->
|
||||
|
||||
<!-- wp:query-pagination {"layout":{"type":"flex","justifyContent":"center"}} -->
|
||||
<!-- wp:query-pagination-previous /-->
|
||||
|
||||
<!-- wp:query-pagination-numbers /-->
|
||||
|
||||
<!-- wp:query-pagination-next /-->
|
||||
<!-- /wp:query-pagination -->
|
||||
|
||||
<!-- wp:query-no-results -->
|
||||
<!-- wp:paragraph {"placeholder":"Add text or blocks that will display when a query returns no results."} -->
|
||||
<p></p>
|
||||
<!-- /wp:paragraph -->
|
||||
<!-- /wp:query-no-results -->
|
||||
</div>
|
||||
<!-- /wp:woocommerce/product-collection -->
|
||||
</div>
|
||||
|
|
|
@ -19,7 +19,7 @@ $content = PatternsHelper::get_pattern_content( 'woocommerce-blocks/product-quer
|
|||
<!-- wp:query {"query":{"perPage":"6","pages":0,"offset":0,"postType":"product","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false,"__woocommerceAttributes":[],"__woocommerceStockStatus":["instock","outofstock","onbackorder"]},"displayLayout":{"type":"flex","columns":3},"namespace":"woocommerce/product-query","align":"wide"} -->
|
||||
<div class="wp-block-query alignwide">
|
||||
<!-- wp:post-template -->
|
||||
<!-- wp:woocommerce/product-image {"saleBadgeAlign":"left","isDescendentOfQueryLoop":true,"style":{"spacing":{"margin":{"bottom":"0.75rem","top":"0"}}}} /-->
|
||||
<!-- wp:woocommerce/product-image {"aspectRatio":"3/4","saleBadgeAlign":"left","isDescendentOfQueryLoop":true,"style":{"spacing":{"margin":{"bottom":"0.75rem","top":"0"}}}} /-->
|
||||
|
||||
<!-- wp:woocommerce/product-rating {"isDescendentOfQueryLoop":true,"textAlign":"center","fontSize":"small","style":{"spacing":{"margin":{"bottom":"0.75rem"}}}} /-->
|
||||
|
||||
|
@ -29,20 +29,6 @@ $content = PatternsHelper::get_pattern_content( 'woocommerce-blocks/product-quer
|
|||
|
||||
<!-- wp:woocommerce/product-price {"isDescendentOfQueryLoop":true,"textAlign":"center","fontSize":"small","style":{"spacing":{"margin":{"bottom":"0.75rem"}}}} /-->
|
||||
<!-- /wp:post-template -->
|
||||
|
||||
<!-- wp:query-pagination {"layout":{"type":"flex","justifyContent":"center"}} -->
|
||||
<!-- wp:query-pagination-previous /-->
|
||||
|
||||
<!-- wp:query-pagination-numbers /-->
|
||||
|
||||
<!-- wp:query-pagination-next /-->
|
||||
<!-- /wp:query-pagination -->
|
||||
|
||||
<!-- wp:query-no-results -->
|
||||
<!-- wp:paragraph {"placeholder":"Add text or blocks that will display when a query returns no results."} -->
|
||||
<p></p>
|
||||
<!-- /wp:paragraph -->
|
||||
<!-- /wp:query-no-results -->
|
||||
</div>
|
||||
<!-- /wp:query -->
|
||||
</div>
|
||||
|
|
|
@ -158,6 +158,9 @@ class ProductImage extends AbstractBlock {
|
|||
if ( ! empty( $attributes['scale'] ) ) {
|
||||
$image_style .= sprintf( 'object-fit:%s;', $attributes['scale'] );
|
||||
}
|
||||
if ( ! empty( $attributes['aspectRatio'] ) ) {
|
||||
$image_style .= sprintf( 'aspect-ratio:%s;', $attributes['aspectRatio'] );
|
||||
}
|
||||
|
||||
if ( ! $product->get_image_id() ) {
|
||||
// The alt text is left empty on purpose, as it's considered a decorative image.
|
||||
|
|
Loading…
Reference in New Issue