Created
February 28, 2020 18:29
-
-
Save vanpariyar/63b8e35482ac086878e46d7519aa534e to your computer and use it in GitHub Desktop.
Gutenberg Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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