Skip to content

Instantly share code, notes, and snippets.

@awakekat
Created December 12, 2018 21:15

Revisions

  1. awakekat created this gist Dec 12, 2018.
    22 changes: 22 additions & 0 deletions esnext-gutenberg-block.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    const { __, setLocaleData } = wp.i18n;
    const { registerBlockType } = wp.blocks;

    const blockStyle = {
    backgroundColor: '#900',
    color: '#fff',
    padding: '20px',
    };

    setLocaleData( window.gutenberg_examples_01_esnext.localeData, 'gutenberg-examples' );

    registerBlockType( 'gutenberg-examples/example-01-basic-esnext', {
    title: __( 'Example: Basic (esnext)', 'gutenberg-examples' ),
    icon: 'universal-access-alt',
    category: 'layout',
    edit() {
    return <div style={ blockStyle }>Basic example with JSX! (editor)</div>;
    },
    save() {
    return <div style={ blockStyle }>Basic example with JSX! (front)</div>;
    },
    } );