components
4 years ago
css
4 years ago
attributes.js
4 years ago
block.js
4 years ago
deprecated.js
5 years ago
edit.js
4 years ago
editor.scss
4 years ago
block.js
56 lines
| 1 | /** |
| 2 | * Block: Button Container |
| 3 | */ |
| 4 | |
| 5 | import './editor.scss'; |
| 6 | |
| 7 | import editButtonContainer from './edit'; |
| 8 | import deprecated from './deprecated'; |
| 9 | import blockAttributes from './attributes'; |
| 10 | import getIcon from '../../utils/get-icon'; |
| 11 | import { __ } from '@wordpress/i18n'; |
| 12 | import { registerBlockType } from '@wordpress/blocks'; |
| 13 | import { InnerBlocks } from '@wordpress/block-editor'; |
| 14 | |
| 15 | /** |
| 16 | * Register our Button Container block. |
| 17 | * |
| 18 | * @param {string} name Block name. |
| 19 | * @param {Object} settings Block settings. |
| 20 | * @return {?WPBlock} The block, if it has been successfully |
| 21 | * registered; otherwise `undefined`. |
| 22 | */ |
| 23 | registerBlockType( 'generateblocks/button-container', { |
| 24 | apiVersion: 2, |
| 25 | title: __( 'Buttons', 'generateblocks' ), |
| 26 | description: __( 'Drive conversions with beautiful buttons.', 'generateblocks' ), |
| 27 | icon: getIcon( 'button-container' ), |
| 28 | category: 'generateblocks', |
| 29 | keywords: [ |
| 30 | __( 'button' ), |
| 31 | __( 'buttons' ), |
| 32 | __( 'generate' ), |
| 33 | ], |
| 34 | attributes: blockAttributes, |
| 35 | supports: { |
| 36 | className: false, |
| 37 | html: false, |
| 38 | }, |
| 39 | usesContext: [ |
| 40 | 'generateblocks/queryId', |
| 41 | 'generateblocks/query', |
| 42 | ], |
| 43 | edit: editButtonContainer, |
| 44 | save: () => { |
| 45 | return ( |
| 46 | <InnerBlocks.Content /> |
| 47 | ); |
| 48 | }, |
| 49 | deprecated, |
| 50 | __experimentalLabel: ( attributes ) => ( |
| 51 | attributes.isPagination |
| 52 | ? __( 'Pagination', 'generateblocks' ) |
| 53 | : __( 'Buttons', 'generateblocks' ) |
| 54 | ), |
| 55 | } ); |
| 56 |