Skip to content

Instantly share code, notes, and snippets.

@mtias
Created June 23, 2017 18:11
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mtias/ecaf95f1c0ab880b18015a1eb3eb7160 to your computer and use it in GitHub Desktop.
Creating a Gutenberg block from the console.
var el = wp.element.createElement;
wp.blocks.registerBlockType( 'mytheme/block', {
title: 'Red Block',
icon: 'universal-access-alt',
category: 'layout',
edit: function() {
return el( 'div', { style: { backgroundColor: '#900', color: '#fff', padding: '20px' } }, 'I am a red block.' );
},
save: function() {
return el( 'div', { style: { backgroundColor: '#900', color: '#fff', padding: '20px' } }, 'I am a red block.' );
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment