All Products: Re-add alignment controls for Product Rating and Price (https://github.com/woocommerce/woocommerce-blocks/pull/8264)

* Product Rating and Price: Re-add alignment controls in the All Products context.

* Add default values to align attributes for price and rating product elements

---------

Co-authored-by: tjcafferkey <tjcafferkey@gmail.com>
This commit is contained in:
Daniel Dudzic 2023-02-21 10:40:14 +01:00 committed by GitHub
parent 33b3a1d82d
commit 34fc847d9f
4 changed files with 14 additions and 17 deletions

View File

@ -14,6 +14,7 @@ export const blockAttributes: BlockAttributes = {
}, },
textAlign: { textAlign: {
type: 'string', type: 'string',
default: 'center',
}, },
}; };

View File

@ -59,14 +59,12 @@ const PriceEdit = ( {
return ( return (
<> <>
<BlockControls> <BlockControls>
{ isDescendentOfQueryLoop && (
<AlignmentToolbar <AlignmentToolbar
value={ attributes.textAlign } value={ attributes.textAlign }
onChange={ ( textAlign: AllowedAlignments ) => { onChange={ ( textAlign: AllowedAlignments ) => {
setAttributes( { textAlign } ); setAttributes( { textAlign } );
} } } }
/> />
) }
</BlockControls> </BlockControls>
<div { ...blockProps }> <div { ...blockProps }>
<Block { ...blockAttrs } /> <Block { ...blockAttrs } />

View File

@ -14,7 +14,7 @@ export const blockAttributes: BlockAttributes = {
}, },
textAlign: { textAlign: {
type: 'string', type: 'string',
default: '', default: 'center',
}, },
}; };

View File

@ -42,14 +42,12 @@ const Edit = ( {
return ( return (
<> <>
<BlockControls> <BlockControls>
{ isDescendentOfQueryLoop && (
<AlignmentToolbar <AlignmentToolbar
value={ attributes.textAlign } value={ attributes.textAlign }
onChange={ ( newAlign ) => { onChange={ ( newAlign ) => {
setAttributes( { textAlign: newAlign || '' } ); setAttributes( { textAlign: newAlign || '' } );
} } } }
/> />
) }
</BlockControls> </BlockControls>
<div { ...blockProps }> <div { ...blockProps }>
<Block { ...blockAttrs } /> <Block { ...blockAttrs } />