Skip to content

Instantly share code, notes, and snippets.

@lucprincen
Created July 31, 2018 19:00
Show Gist options
  • Save lucprincen/6a3dc6e5aa3228cde8fc5c194d871719 to your computer and use it in GitHub Desktop.
Save lucprincen/6a3dc6e5aa3228cde8fc5c194d871719 to your computer and use it in GitHub Desktop.

Revisions

  1. lucprincen created this gist Jul 31, 2018.
    33 changes: 33 additions & 0 deletions container-block.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    const { __ } = wp.i18n;
    const { InnerBlocks } = wp.editor;
    const { registerBlockType } = wp.blocks;

    registerBlockType(
    'kit/container',
    {
    title: __('Container'),
    description: __('Add a container for blocks'),
    category: 'common',
    supports: { html: false },

    edit(props) {

    const { className } = props;
    return (
    <div className={className}>
    <InnerBlocks />
    </div>
    );
    },
    save(props) {

    const { className } = props;
    return (
    <section className={className}>
    <InnerBlocks.Content/>
    </section>
    );
    }

    }
    )