WebDevStudios library of Gutenberg blocks.
- Hero
- Call To Action
- Recent Posts Grid
- Multi-select, Related Posts Grid
- Two Column Layout
- Github Gist
- Users Grid
WDS Blocks also come with a robust set of options: background image, video, and color support. Plus, text color, custom CSS classes, and Animate.css support. These blocks have been tested with our starter theme, wd_s.
You must have the Gutenberg plugin installed and activated.
- Clone or download a .zip
- Rename
WDS-Blocks-x.x
towds-blocks
- Place
wds-blocks
into/plugins/
- Activate this plugin
Head on over to a post or page, and start inserting WDS Blocks!
Check out the Wiki for more info.
Your contributions are welcome. Here's a quick start guide to developing with WDS Blocks.
There is a "Default Block" which is intended to be a jumping off point. Read the Default Block page on the wiki for more.
- Blocks are stored in the
/src/blocks/
directory. These are the blocks that users can insert into posts in the wp-admin. - Components are stored in the
/src/components/
directory. These individual components can can be imported into and used by one or more blocks. Example: If block A and block B both display a dropdown of recent posts, a recent posts component could be created, then imported into and used by both of those blocks.
Please use the following file naming convention for all blocks for consistency:
my-block
├── editor.scss (styles for the backend only)
├── endpoints.php (any REST API endpoints)
├── icon.js (the block's SVG icon)
├── index.js (required to register the block)
├── render.php (the PHP render callback function for dynamic blocks)
└── style.scss (styles for both frontend & backend)
index.js
is the only file that is required, since that's where the block is registered. Beyond any listed above, your block can also include additional files, as needed - just give them names that make sense.
- Inside of
/src/blocks/
, duplicate thedefault
block and rename it. - Inside of that new directory, open the
index.js
file. This is where the call toregisterBlockType()
to register the block needs to be. - Inside of
/src/blocks.js
, add a line like the following to import your new block:import './blocks/my-block';
. This will ensure that you're new block is included in the webpack build process. - For any other JS or SCSS files your block uses, be sure to
import
them from withinindex.js
. Any PHP files included in your block's directory will be loaded up automatically – you don't need to worry about addingrequire
/include
statements anywhere. - Namespace any PHP files using the name of your block, such as:
namespace WDS\Blocks\block\my_block;
.
- Please write all JavaScript using modern ES6+/ESNext syntax. Webpack is configured to transpile all JS down into ES5 syntax that will work on all browsers, so don't hesitate to use modern JS language features in your code that aren't fully supported by all major browsers yet.
- The project contains an
.eslintrc.json
file that contains JS linting rulesets. Please turn on linting in your editor and format your JS code accordingly.
- Use to compile and run the block in development mode.
- Watches for any changes and reports back any errors in your code.
- Use to build production code for your block inside
dist
folder. - Runs once and reports back the gzip file sizes of the produced code.
- Use to eject your plugin out of
create-guten-block
. - Provides all the configurations so you can customize the project as you want.
- It's a one-way street,
eject
and you have to maintain everything yourself. - You don't normally have to
eject
a project because by ejecting you lose the connection withcreate-guten-block
and from there onwards you have to update and maintain all the dependencies on your own.
Your contributions are welcome. Please follow the contribution guidelines.
This project was bootstrapped with Create Guten Block.