Git Product home page Git Product logo

block-experiments's Introduction

Block Experiments

A monorepo of block experiments by the fine folks at Automattic.

About

This repository holds a collection of blocks allowing a single place to develop, test, and package. Plus it allows a single place for user's to submit issues.

To make development easier, the build script allows for building and bundling all of the blocks together.

For packaging, each block can be generated as its own stand-alone plugin.

Development

  1. Install node packages: yarn install

  2. Run the development build with: yarn start (or) Run a production build with: yarn build

  3. Once built, add copy this directory (or add a symlink) to your plugins directory.

  4. Activate Block Experiments plugin, use blocks in Editor.

Adding a block

Add a directory to blocks, ensure your block has:

  • your-block/index.php - the block plugin file to register your block
  • your-block/src/index.js - the JS init file
  • your-block/editor.scss - the editor SCSS file
  • your-block/style.scss - the editor/front SCSS file

When registering your block, use these values so it works when used inside of the bundle:

register_block_type( 'jetpack/your-block-name', [
	'editor_script' => 'wpcom-blocks',
	'style' => 'wpcom-blocks',
	'editor_style' => 'wpcom-blocks-editor',
] );

Packaging a Plugin

The plugin bundler takes a set of blocks and builds a WordPress plugin, suitable for inclusion on a standalone site or WordPress.com.

The bundler uses a JSON file to list the blocks to bundle. These JSON files are stored in bundler/bundles and look like:

{
	"blocks": [
		"block name"
	],
	"labs": true,
	"version": 0.1
}

The block names are listed under blocks, and the plugin version under version. If the bundle includes Tinker Labs blocks then set the labs to true so that the appropriate categories are also included.

Some blocks may require additional files, such as front end JS or CSS. These can be specified in manifest files, located in the block directory under index.json:

[
	"extra.js",
	"extra.css"
]
  1. Set the plugin bundle to build: yarn plugin [bundle-name]

  2. Build the plugin: yarn bundle

The plugin zip file can be found at: bundles/bundle-name.zip

block-experiments's People

Contributors

ajlende avatar jasmussen avatar johngodley avatar mkaz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.