Skip to content

Commit 6ab5eb4

Browse files
committed
πŸ“– DOC: Refactor JSDoc
1 parent 07e3264 commit 6ab5eb4

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

β€Žpackages/cgb-scripts/template/src/block/block.jsβ€Ž

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77

88
// Import CSS.
9-
import './style.scss';
109
import './editor.scss';
10+
import './style.scss';
1111

1212
const { __ } = wp.i18n; // Import __() from wp.i18n
1313
const { registerBlockType } = wp.blocks; // Import registerBlockType() from wp.blocks
@@ -43,8 +43,11 @@ registerBlockType( 'cgb/block-<% blockName %>', {
4343
* The "edit" property must be a valid function.
4444
*
4545
* @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
46+
*
47+
* @param {Object} props Props.
48+
* @returns {Mixed} JSX Component.
4649
*/
47-
edit: function( props ) {
50+
edit: ( props ) => {
4851
// Creates a <p class='wp-block-cgb-block-<% blockName %>'></p>.
4952
return (
5053
<div className={ props.className }>
@@ -71,10 +74,13 @@ registerBlockType( 'cgb/block-<% blockName %>', {
7174
* The "save" property must be specified and must be a valid function.
7275
*
7376
* @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
77+
*
78+
* @param {Object} props Props.
79+
* @returns {Mixed} JSX Frontend HTML.
7480
*/
75-
save: function( props ) {
81+
save: ( props ) => {
7682
return (
77-
<div>
83+
<div className={ props.className }>
7884
<p>β€” Hello from the frontend.</p>
7985
<p>
8086
CGB BLOCK: <code><% blockName %></code> is a new Gutenberg block.

β€Žpackages/cgb-scripts/template/src/init.phpβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ function <% blockNamePHPLower %>_cgb_block_assets() { // phpcs:ignore
5353
null // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
5454
);
5555

56-
// Localised globals. Use dynamic PHP stuff in JavaScript via `cgbGlobal object.
56+
// Localized globals. Use dynamic PHP stuff in JavaScript via `cgbGlobal` object.
5757
wp_localize_script(
5858
'<% blockNamePHPLower %>-cgb-block-js',
5959
'cgbGlobal', // Array containing dynamic data for a JS Global.
6060
[
6161
'pluginDirPath' => plugin_dir_path( __DIR__ ),
6262
'pluginDirUrl' => plugin_dir_url( __DIR__ ),
63-
// Add more data here that you want to access from cgbGlobal object.
63+
// Add more data here that you want to access from `cgbGlobal` object.
6464
]
6565
);
6666

0 commit comments

Comments
Β (0)