This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add to the Product Button block the support for the Product Query blo…
…ck (#6948) * Adds to the Product Image Block the support for the Product Query Block Adds to the Product Image Block the support for the Product Query Block #6911 * use shared config * use shared config * use shared config * Add to the Product Button Block the support for the Product Query Block * Add to the Product Image Block the support for the Product Query Block * fix lint errors * address feedback * set grid view and font-size L as default
- Loading branch information
Showing
5 changed files
with
81 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,30 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { Disabled } from '@wordpress/components'; | ||
import { useBlockProps } from '@wordpress/block-editor'; | ||
import { useEffect } from 'react'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Block from './block'; | ||
import withProductSelector from '../shared/with-product-selector'; | ||
import { BLOCK_TITLE, BLOCK_ICON } from './constants'; | ||
|
||
const Edit = ( { attributes } ) => { | ||
const Edit = ( { attributes, setAttributes, context } ) => { | ||
const blockProps = useBlockProps(); | ||
const isDescendentOfQueryLoop = Number.isFinite( context.queryId ); | ||
|
||
useEffect( | ||
() => setAttributes( { isDescendentOfQueryLoop } ), | ||
[ setAttributes, isDescendentOfQueryLoop ] | ||
); | ||
return ( | ||
<div { ...blockProps }> | ||
<Disabled> | ||
<Block { ...attributes } /> | ||
<Block { ...{ ...attributes, ...context } } /> | ||
</Disabled> | ||
</div> | ||
); | ||
}; | ||
|
||
export default withProductSelector( { | ||
icon: BLOCK_ICON, | ||
label: BLOCK_TITLE, | ||
description: __( | ||
'Choose a product to display its add to cart button.', | ||
'woo-gutenberg-products-block' | ||
), | ||
} )( Edit ); | ||
export default Edit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters