-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathedit.js.mustache
More file actions
50 lines (46 loc) · 1.41 KB
/
edit.js.mustache
File metadata and controls
50 lines (46 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { __ } from '@wordpress/i18n';
import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
import { PanelBody, TextControl } from '@wordpress/components';
{{#isDynamicVariant}}
import { ServerSideRender } from '@wordpress/server-side-render';
{{/isDynamicVariant}}
import './editor.pcss';
export default function Edit( { attributes, setAttributes, isSelected } ) {
const blockProps = useBlockProps();
const { exampleTextControl } = attributes;
return (
<div { ...blockProps }>
{{#isDynamicVariant}}
<ServerSideRender
block="tribe/test-dynamic"
attributes={ attributes }
/>
{{/isDynamicVariant}}
{{#isStaticVariant}}
<p>{ __( '{{title}} – hello from the editor!', '{{namespace}}' ) }</p>
{ exampleTextControl ? <p>{ exampleTextControl }</p> : '' }
{{/isStaticVariant}}
{ isSelected && (
<InspectorControls>
<PanelBody title={ __( 'Block Settings', '{{namespace}}' ) }>
<TextControl
label={ __( 'Example Text Control', '{{namespace}}' ) }
value={ exampleTextControl }
help={ __(
'Some helpful text describing the text control.',
'{{namespace}}'
) }
placeholder={ __(
'Helpful placeholder text',
'{{namespace}}'
) }
onChange={ ( value ) =>
setAttributes( { exampleTextControl: value } )
}
/>
</PanelBody>
</InspectorControls>
) }
</div>
);
}