block.js
39 lines
| 1 | /** |
| 2 | * WordPress dependencies |
| 3 | */ |
| 4 | const ServerSideRender = wp.serverSideRender; |
| 5 | |
| 6 | /** |
| 7 | * Internal dependencies |
| 8 | */ |
| 9 | import './block.scss'; |
| 10 | import SelectForm from '../../components/select-form'; |
| 11 | import Inspector from './inspector'; |
| 12 | |
| 13 | /** |
| 14 | * Render Block UI For Editor |
| 15 | */ |
| 16 | |
| 17 | const GiveForm = ( props ) => { |
| 18 | const { attributes, isSelected, className } = props; |
| 19 | const { id } = attributes; |
| 20 | |
| 21 | // Render block UI |
| 22 | let blockUI; |
| 23 | |
| 24 | if ( ! id ) { |
| 25 | blockUI = <SelectForm { ... { ...props } } />; |
| 26 | } else { |
| 27 | blockUI = ( |
| 28 | <div className={ !! isSelected ? `${ className } isSelected` : className } > |
| 29 | <Inspector { ... { ...props } } /> |
| 30 | <ServerSideRender block="give/donation-form" attributes={ attributes } /> |
| 31 | </div> |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | return blockUI; |
| 36 | }; |
| 37 | |
| 38 | export default GiveForm; |
| 39 |