| 1 |
/** |
| 2 |
* External dependencies |
| 3 |
*/ |
| 4 |
import clsx from 'clsx'; |
| 5 |
|
| 6 |
/** |
| 7 |
* WordPress dependencies |
| 8 |
*/ |
| 9 |
import { useBlockProps } from '@wordpress/block-editor'; |
| 10 |
import './editor.scss'; |
| 11 |
import './style.scss'; |
| 12 |
|
| 13 |
import Controls from './controls'; |
| 14 |
import PostCountBlock from './post-count-block'; // Import the new component |
| 15 |
|
| 16 |
/** |
| 17 |
* The edit function describes the structure of your block in the context of the |
| 18 |
* editor. This represents what the editor will render when the block is used. |
| 19 |
* |
| 20 |
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit |
| 21 |
* |
| 22 |
* @param {Object} root0 - The root object containing block properties. |
| 23 |
* @param {Object} root0.context - The context of the block. |
| 24 |
* @param {Object} root0.attributes - The attributes of the block. |
| 25 |
* @param {Function} root0.setAttributes - Function to set the block's attributes. |
| 26 |
* |
| 27 |
* @return {Element} Element to render. |
| 28 |
*/ |
| 29 |
export default function Edit({ context, attributes, setAttributes }) { |
| 30 |
const { textAlign } = attributes; |
| 31 |
|
| 32 |
const blockProps = useBlockProps({ |
| 33 |
className: clsx({ |
| 34 |
[`has-text-align-${textAlign}`]: textAlign, |
| 35 |
}), |
| 36 |
}); |
| 37 |
|
| 38 |
return ( |
| 39 |
<> |
| 40 |
<Controls attributes={attributes} setAttributes={setAttributes} /> |
| 41 |
<div {...blockProps}> |
| 42 |
<PostCountBlock attributes={attributes} context={context} /> |
| 43 |
</div> |
| 44 |
</> |
| 45 |
); |
| 46 |
} |
| 47 |
|