Skip to content

Commit

Permalink
Add TextControl in the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
donmhico committed Mar 4, 2020
1 parent 2f675b4 commit cc6abb0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
21 changes: 21 additions & 0 deletions src/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Component } from '@wordpress/element';
import { TextControl } from '@wordpress/components';

export default class Edit extends Component {
render() {
const {
attributes: {
search
},
setAttributes,
} = this.props;

return (
<TextControl
label="Search GIF"
value={ search }
onChange={ search => setAttributes( { search } )}
/>
);
}
}
16 changes: 9 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { registerBlockType } from '@wordpress/blocks';
*/
import { __ } from '@wordpress/i18n';

import edit from './edit';

/**
* Every block starts by registering a new block type definition.
*
Expand Down Expand Up @@ -45,6 +47,12 @@ registerBlockType( 'create-block/giphy-block', {
*/
icon: 'smiley',

attributes: {
search: {
type: 'string'
}
},

/**
* Optional block extended support features.
*/
Expand All @@ -63,13 +71,7 @@ registerBlockType( 'create-block/giphy-block', {
*
* @return {WPElement} Element to render.
*/
edit( { className } ) {
return (
<p className={ className }>
{ __( 'Giphy Block – hello from the editor!', 'create-block' ) }
</p>
);
},
edit,

/**
* The save function defines the way in which the different attributes should be combined
Expand Down

0 comments on commit cc6abb0

Please sign in to comment.