| @@ -10,37 +10,30 @@ | ||
| 10 | 10 | import './editor.scss'; |
| 11 | 11 | import './style.scss'; |
| 12 | 12 | |
| 13 | 13 | import Controls from './controls'; |
| 14 | -import PostCountBlock from './post-count-block'; // Import the new component | |
| 14 | +import PostCountBlock from './post-count-block'; | |
| 15 | 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 }) { | |
| 16 | +export default function Edit( { context, attributes, setAttributes } ) { | |
| 30 | 17 | const { textAlign } = attributes; |
| 31 | 18 | |
| 32 | - const blockProps = useBlockProps({ | |
| 33 | - className: clsx({ | |
| 34 | - [`has-text-align-${textAlign}`]: textAlign, | |
| 35 | - }), | |
| 36 | - }); | |
| 19 | + const blockProps = useBlockProps( { | |
| 20 | + className: clsx( 'wp-block-tptn-post-count', 'tptn-post-count', { | |
| 21 | + [ `has-text-align-${ textAlign }` ]: textAlign, | |
| 22 | + 'tptn-advanced-mode': attributes.advancedMode, | |
| 23 | + } ), | |
| 24 | + } ); | |
| 37 | 25 | |
| 38 | 26 | return ( |
| 39 | 27 | <> |
| 40 | - <Controls attributes={attributes} setAttributes={setAttributes} /> | |
| 41 | - <div {...blockProps}> | |
| 42 | - <PostCountBlock attributes={attributes} context={context} /> | |
| 43 | - </div> | |
| 28 | + <Controls | |
| 29 | + attributes={ attributes } | |
| 30 | + setAttributes={ setAttributes } | |
| 31 | + /> | |
| 32 | + <PostCountBlock | |
| 33 | + attributes={ attributes } | |
| 34 | + context={ context } | |
| 35 | + blockProps={ blockProps } | |
| 36 | + /> | |
| 44 | 37 | </> |
| 45 | 38 | ); |
| 46 | 39 | } |