PluginProbe
WebberZone Top 10 — Popular Posts / 4.3.2
WebberZone Top 10 — Popular Posts v4.3.2
4.5.1 4.5.0 4.4.3 4.4.2 4.4.1 4.4.0 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 trunk 1.0 1.0.1 1.1 1.2 1.3 1.4 1.4.1 1.5 1.5.1 1.5.2 1.5.3 1.6 1.6.1 All 117 releases
top-10 / includes / frontend / blocks / src / post-count / edit.js

edit.js in WebberZone Top 10 — Popular Posts 4.3.2, at includes/frontend/blocks/src/post-count/edit.js

47 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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