A line across or down the page, with stops along it. Your client bends the line by dragging its nodes in the editor, and fills each stop with any blocks. On the page the line draws itself as the visitor scrolls and each stop appears as the line reaches it. The stops can also be filled from posts.
Download example A zip of block folders for your theme. Needs GCB 1.3.1 or later, and nothing else.
What's in the download
path/The path: the line and its nodes, how long it holds on screen, and the option to fill the stops from posts.layout-box/One stop. Any blocks inside.
Each folder is an ordinary GCB block: block.json, block.fields.json and render.php, plus a style.css and a view.js where it needs them. There is no build step and no library.
How it's built
The line is one field of the path type: the editor draws it as a line with nodes your client drags, and stores the points. The stops are child blocks, marked with a <Repeater> that names the block a stop is and how many there can be.
<Repeater allowedBlocks='["gcb/layout-box"]' addButtonLabel="Add node" min="1" max="60" editLayout="grid"/>Its fields, from block.fields.json:
| Field | Type |
|---|---|
| The line and its nodes | path |
| How long it holds | range |
| Fill from posts | toggle |
| Which posts | query-loop |
view.js is about 8 KB of plain JavaScript. With no script, the whole line and every stop show.
Use it
- Unzip the download.
- Copy
path/andlayout-box/into your theme'sblocks/folder. - Reload the block editor. The block is in the inserter.
That's all of it. You don't register the block: there's no register_block_type() call and nothing to add to functions.php. GCB registers every folder in your theme's blocks/ folder by itself.
It is your block now. Change the markup, the fields or the script to suit the design. The docs cover every field type and marker used here.
More examples: all examples, or download them together as the GCB Kit.