| 1 |
/** |
| 2 |
* BLOCK: uji-countdown-2020 |
| 3 |
* |
| 4 |
* Registering a basic block with Gutenberg. |
| 5 |
* Simple block, renders and saves the same content without any interactivity. |
| 6 |
*/ |
| 7 |
|
| 8 |
// Import CSS. |
| 9 |
|
| 10 |
//import './editor.scss'; |
| 11 |
//import './style.scss'; |
| 12 |
|
| 13 |
import metadata from './block.json'; |
| 14 |
import edit from './edit'; |
| 15 |
import save from './save'; |
| 16 |
|
| 17 |
const { __ } = wp.i18n; // Import __() from wp.i18n |
| 18 |
const { registerBlockType } = wp.blocks; // Import registerBlockType() from wp.blocks |
| 19 |
|
| 20 |
const { name, category, attributes } = metadata; |
| 21 |
|
| 22 |
/** |
| 23 |
* Register: aa Gutenberg Block. |
| 24 |
* |
| 25 |
* Registers a new block provided a unique name and an object defining its |
| 26 |
* behavior. Once registered, the block is made editor as an option to any |
| 27 |
* editor interface where blocks are implemented. |
| 28 |
* |
| 29 |
* @link https://wordpress.org/gutenberg/handbook/block-api/ |
| 30 |
* @param {string} name Block name. |
| 31 |
* @param {Object} settings Block settings. |
| 32 |
* @return {?WPBlock} The block, if it has been successfully |
| 33 |
* registered; otherwise `undefined`. |
| 34 |
*/ |
| 35 |
registerBlockType(name, { |
| 36 |
// Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block. |
| 37 |
title: __('Uji Countdown'), // Block title. |
| 38 |
icon: 'clock', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
| 39 |
category, // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
| 40 |
keywords: [__('Uji Countdown'), __('Countdown Timer'), __('uji-countdown')], |
| 41 |
|
| 42 |
attributes, |
| 43 |
|
| 44 |
/** |
| 45 |
* The edit function describes the structure of your block in the context of the editor. |
| 46 |
* This represents what the editor will render when the block is used. |
| 47 |
* |
| 48 |
* The "edit" property must be a valid function. |
| 49 |
* |
| 50 |
* @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ |
| 51 |
* |
| 52 |
* @param {Object} props Props. |
| 53 |
* @returns {Mixed} JSX Component. |
| 54 |
*/ |
| 55 |
edit, |
| 56 |
|
| 57 |
/** |
| 58 |
* The save function defines the way in which the different attributes should be combined |
| 59 |
* into the final markup, which is then serialized by Gutenberg into post_content. |
| 60 |
* |
| 61 |
* The "save" property must be specified and must be a valid function. |
| 62 |
* |
| 63 |
* @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/ |
| 64 |
* |
| 65 |
* @param {Object} props Props. |
| 66 |
* @returns {Mixed} JSX Frontend HTML. |
| 67 |
*/ |
| 68 |
save, |
| 69 |
}); |
| 70 |
|