|
1 | 1 | /** |
2 | 2 | * WordPress dependencies |
3 | 3 | */ |
4 | | -import { useBlockProps, InspectorControls, InnerBlocks, RichText } from '@wordpress/block-editor'; |
5 | | -import { PanelBody, TextareaControl } from '@wordpress/components'; |
| 4 | +import { useBlockProps, InspectorControls, InnerBlocks } from '@wordpress/block-editor'; |
6 | 5 | import { __ } from '@wordpress/i18n'; |
7 | 6 |
|
8 | 7 | /** |
9 | 8 | * Edit function for the Content Gate Countdown block. |
10 | 9 | * |
11 | | - * @param {Object} props The block properties. |
12 | | - * @param {Object} props.attributes The block attributes. |
13 | | - * @param {Function} props.setAttributes The block attributes setter. |
14 | | - * |
15 | 10 | * @return {JSX.Element} The Content Gate Countdown block. |
16 | 11 | */ |
17 | | -export default function Edit( { attributes, setAttributes } ) { |
| 12 | +export default function Edit() { |
18 | 13 | const blockProps = useBlockProps(); |
19 | | - const { text } = attributes; |
20 | | - |
21 | | - const handleChange = ( key, value ) => { |
22 | | - setAttributes( { [ key ]: value } ); |
23 | | - }; |
24 | 14 |
|
25 | 15 | return ( |
26 | 16 | <> |
27 | | - <InspectorControls> |
28 | | - <PanelBody title={ __( 'Content Gate Countdown Settings', 'newspack-plugin' ) }> |
29 | | - <TextareaControl |
30 | | - label={ __( 'Text', 'newspack-plugin' ) } |
31 | | - value={ text } |
32 | | - onChange={ value => handleChange( 'text', value ) } |
33 | | - placeholder={ __( 'Get unlimited access.', 'newspack-plugin' ) } |
34 | | - help={ __( 'The call to action text that appears above the subscribe button.', 'newspack-plugin' ) } |
35 | | - /> |
36 | | - </PanelBody> |
37 | | - </InspectorControls> |
38 | | - |
39 | | - <div { ...blockProps }> |
40 | | - <div className="wp-block-newspack-content-gate-countdown__content"> |
41 | | - <div className="wp-block-newspack-content-gate-countdown__notice"> |
42 | | - { ' ' } |
43 | | - <span className="wp-block-newspack-content-gate-countdown__views">3 / 3</span> |
| 17 | + <InspectorControls /> |
| 18 | + <div className="newspack-content-gate-countdown" { ...blockProps }> |
| 19 | + <div className="newspack-content-gate-countdown__content"> |
| 20 | + <div className="newspack-content-gate-countdown__notice"> |
| 21 | + <span className="newspack-content-gate-countdown__countdown">3 / 3</span> |
44 | 22 | <p>{ __( 'remaining articles this month.', 'newspack-plugin' ) }</p> |
45 | 23 | </div> |
46 | | - <div className="wp-blocks-newspack-content-gate-countdown__actions"> |
47 | | - <RichText |
48 | | - tagName="div" |
49 | | - className="wp-block-newspack-blocks-content-gate-countdown__text" |
50 | | - value={ text } |
51 | | - onChange={ value => handleChange( 'text', value ) } |
52 | | - placeholder={ __( 'CTA text…', 'newspack-plugin' ) } |
53 | | - allowedFormats={ [] } |
54 | | - /> |
| 24 | + <div className="newspack-content-gate-countdown__actions"> |
55 | 25 | <InnerBlocks |
56 | | - allowedBlocks={ [ 'newspack-blocks/checkout-button', 'core/buttons' ] } |
57 | | - template={ [ [ 'newspack-blocks/checkout-button', { text: __( 'Subscribe now', 'newspack-plugin' ) } ] ] } |
| 26 | + allowedBlocks={ [ 'newspack-blocks/checkout-button', 'core/buttons', 'core/paragraph' ] } |
| 27 | + template={ [ |
| 28 | + [ 'core/paragraph', { content: __( 'Get unlimited access.', 'newspack-plugin' ) } ], |
| 29 | + [ 'newspack-blocks/checkout-button', { text: __( 'Subscribe now', 'newspack-plugin' ) } ], |
| 30 | + ] } |
58 | 31 | /> |
59 | 32 | </div> |
60 | 33 | </div> |
|
0 commit comments