WP Manifestindependent plugin directory
manifest / editor / gutenberg-blocks

Gutenberg Blocks

Simple WordPress plugin with a group of custom Gutenberg blocks written with Javascript and JSX support

★ 0stars
1release downloads
release-2ff74-20240830111931latest · 2 years ago

Install

Download release-2ff74-20240830111931.zip From the release-2ff74-20240830111931 release on GitHub, Aug 30, 2024

Upload it under Plugins → Add New Plugin → Upload Plugin, then activate.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/adrianahdez/gutenberg-blocks/releases/download/release-2ff74-20240830111931/release-2ff74-20240830111931.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Simple WordPress plugin with a group of custom reusable Gutenberg blocks to use on any project. Written with PHP, Javascript and JSX support – build step required.

Installation

  1. Upload the plugin files to the /wp-content/plugins/gutenberg-blocks directory.
  2. Activate the plugin through the 'Plugins' screen in WordPress
  3. Build assets: Go to the plugin folder from terminal, and run these commands (v19.6.0 of Node is recommended):
    npm install
    gulp
    npm run build
  4. Enjoy!

Contributing

You are welcome to contribute with this project. You can create a fork from this repository and send PRs or open issues here.

How we reuse React Components in dynamic blocks

We build our dynamic blocks as a React component that isn't aware of Gutenberg. That block accepts a prop that is used to pass block attributes. But for now, Gutenberg only allow to render the dynamic blocks using PHP. So, to be able to reuse the same React Component that we have in the Edit function we based on this article from WooCommerce.

And what we do basically is:

  • When the post or page is saved, only an empty div element with an ID or class is saved to the Database.
  • In the PHP render_callback, we append the block attributes as data- HTML attributes to that div. So this is what ends up being rendered in the page.
  • We enqueue a new frontend.js file which will import the React component.
  • From there, we just need to render the React component as you would render any other React app: render(BlockComponent, divElement). We read data- HTML attributes and pass them as props to the component.

License

WordPress is free software, and is released under the terms of the GNU General Public License version 2 or (at your option) any later version.

Changelog

  • 0.1.0
    • Release

Releases

1 release. Each count is every asset in that release; expand a row for the breakdown.

Tag
Published
Assets
Downloads
Aug 30, 2024 2 years ago
release-2ff74-20240830111931.zip
1