Rich Tabor + JR Tashjian + Evan Herman + Anthony Ledesma
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
GitHub: http://github.com/richtabor/building-blocks
Download the project + add it to your local environment (or Docker, via the instructions in the project)
CoBlocks Co-Founder – ThemeBeans Founder – Joined GoDaddy April 2019
Full Stack Engineer – WordPress & Gutenberg Contributor
WordPress specialist – Lover of APIs – Cat Herder
Full Stack Engineer – WordPress & Gutenberg Contributor
Today's Goal:
Which we'll tackle today!
├── your-plugin.php
├── package.json
├── build
├── index.js
├── style.css
├── editor.css
└── src
├── block.js
├── edit.js
├── icon.js
├── index.js
├── save.js
├── style.scss
├── editor.scss
// Block Javascript
wp_register_script(
'building-blocks',
plugins_url( 'build/index.js', __FILE__ ),
$asset_file['dependencies'],
$asset_file['version'],
);
// Editor Styling
wp_register_style(
'building-blocks-editor',
plugins_url( 'editor.css', __FILE__ ),
array( 'wp-edit-blocks' ),
$asset_file['version']
);
// Frontend Styling
wp_register_style(
'building-blocks-frontend',
plugins_url( 'style.css', __FILE__ ),
array(),
$asset_file['version']
);
// Register block
register_block_type(
'building-blocks/author',
array(
'editor_script' => 'building-blocks',
'style' => 'building-blocks-frontend',
'editor_style' => 'building-blocks-editor',
)
);
registerBlockType( 'building-blocks/author', {
title: __( 'Building Blocks (Author)', 'building-blocks' ),
icon: 'user',
category: 'common',
example: {},
attributes: {},
edit() {
return (
<div>Hello from the editor</div>
);
},
save() {
return (
<div>Hello from the front-end</div>
);
},
} );
attributes: {
content: {
type: 'array',
source: 'children',
selector: 'p',
},
alignment: {
type: 'string',
default: 'none',
},
},
edit: ( props ) => {
const { attributes: { content }, setAttributes, className } = props;
const onChangeContent = ( newContent ) => {
setAttributes( { content: newContent } );
};
return (
<RichText
tagName="p"
className={ className }
onChange={ onChangeContent }
value={ content }
/>
);
},
save: ( props ) => {
return <RichText.Content tagName="p" value={ props.attributes.content } />;
},
docker-compose up -d
http://localhost:9999/
npm install
npm start
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor
Slides: http://slides.com/richtabor/building-blocks
Need help later? I'm on Twitter @richard_tabor