Custom Blocks
Sometimes editors need a custom layout inside the content. Custom blocks for the block editor cover this.
note
The template doesn't include a custom block plugin. When a project needs custom blocks, we use Lazy Blocks.
Naming
Match the block slug with the template file, the HTML class and the SCSS file.
| Name | |
|---|---|
| Block template | blocks/lazyblock-{slug}/block.php |
| HTML class | .c-block-{slug} |
| SCSS file | data/scss/object/component/_block-{slug}.scss |
Example
A foo block:
// blocks/lazyblock-foo/block.php
<div class="c-block-foo">
<div class="c-block-foo__child">
<?php /** Something actions */ ?>
</div>
</div>
// data/scss/object/component/_block-foo.scss
.c-block-foo {
&__child {
// Something styles
}
}