Nicola Heald
will be doing the talking soon
Webpack? Babel? ESWhat? Transpiling JSX?
Make sure you have npm installed
$ npx create-guten-block my-block
$ cd my-block
$ npm start
Blocks have
import './style.scss';
import './editor.scss';
const attributes = {
quote: {
type: 'string'
}
};
function edit( props ) {
const setQuote = ( changeEvent ) => {
props.setAttributes( { quote: changeEvent.target.value } );
};
return (
<div>
<p>Pick your favourite Obi-Wan quote!</p>
<select onChange={ setQuote }>
<option></option>
<option>Hello there!</option>
<option>They'll be back, and in greater numbers.</option>
<option>Darth Vader is your dad!</option>
</select>
</div>
);
}
function save( props ) {
return <p>{ props.attributes.quote }</p>;
}
wp.blocks.registerBlockType( 'cgb/block-my-block', {
title: wp.i18n.__( 'my-block - CGB Block' ), // Block title.
icon: 'shield',
category: 'common',
edit: edit,
save: save,
attributes: attributes,
} );
slides available at http://notnownikki.com/talks/