Giter Club home page Giter Club logo

blocks's Introduction

giantpeach/blocks

Schnapps License

Description

This package aims to simplify block creation and usage in Wordpress. It is designed and included as part of the Peach Schnapps Framework.

It can be used independently, but is designed to work with the other packages in the framework.

Updates and changes to this package are dictated by the projects we work on and their needs, they may not necessarily be backwards compatible.

Installation

composer require giantpeach/blocks

Usage

The package consists of a couple of classes that can be extended to create custom blocks.

The Block class provides a number of methods to simplify block creation and usage and hides away the complexity (block registration, template loading etc) so your extended class can focus on the block's functionality.

The Blocks class handles the actual registration of all your blocks and the traits they use. Typically, you would extend this class in your theme and add your blocks to it.

Quickstart

Once you've extended the Blocks class it registers a WP CLI command to create new blocks. You can use this to create a new block:

wp giantpeach create-block MyBlock [--prose] [--spacing]

This command will scaffold a new block within your theme, including the block controller class, the block json and the twig template.

Optionally you can specify whether the block should use the Prose or Spacing traits.

Traits

The package includes a number of traits that can be used to add functionality to your blocks. These are:

  • Prose - adds a prose and creates a few ACF fields for use with the Block to modify prose styles
  • Spacing - adds spacing classes to the block wrapper and creates a few ACF fields for use with the Block to modify spacing styles. The spacing classes are based on the Tailwind CSS spacing classes, and can be overwritten on the Block by setting the $blockSpacing array.

Additional Classes

The package also include a few additional classes that can be helpful to use with your blocks:

  • Classes - a class to handle the creation of classes for use with your blocks. This class is used to create classes for the prose and spacing traits, but can also be used to create classes for any other purpose.
  • Style - a class to handle inline styles for use with your blocks. Style tags will automatically be added to the head of the document.

License

This package is open source and is licensed under the MIT License.

blocks's People

Contributors

bush95 avatar

Watchers

Tom 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.