Skip to content

Instantly share code, notes, and snippets.

@vanpariyar
Created February 28, 2020 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanpariyar/63b8e35482ac086878e46d7519aa534e to your computer and use it in GitHub Desktop.
Save vanpariyar/63b8e35482ac086878e46d7519aa534e to your computer and use it in GitHub Desktop.
Gutenberg Demo
wp.blocks.registerBlockType('guten/guten-box',{
title: 'my cool Border box',
icon: 'smiley',
category: 'common',
attributes: {
content:{type: 'string'},
color: {type: 'string'}
},
edit: function( props ){
function updateContent( event ){
props.setAttributes({content: event.target.value})
}
function updateColor( value ){
props.setAttributes( { color:value.hex } )
}
return wp.element.createElement(
'div',
null,
wp.element.createElement(
'h3',
{style: { color: props.attributes.color } },
'your cooll border box'
),
React.createElement('input', {type: 'text' , value: props.attributes.content , onChange: updateContent}),
React.createElement(wp.components.ColorPicker, { color: props.attributes.color, onChangeComplete: updateColor }),
);
},
save: function( props ){
return wp.element.createElement(
'div',
null,
wp.element.createElement(
'h3',
{style: { color: props.attributes.color } },
'your cooll border box'
),
React.createElement('input', {type: 'text', value: props.attributes.content})
);
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment