Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Child Blocks like Child Themes #37705

Closed
DJviolin opened this issue Jan 4, 2022 · 3 comments
Closed

Add support for Child Blocks like Child Themes #37705

DJviolin opened this issue Jan 4, 2022 · 3 comments
Labels
[Status] Needs More Info Follow-up required in order to be actionable. [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed.

Comments

@DJviolin
Copy link

DJviolin commented Jan 4, 2022

What problem does this address?

This feature request only resembles similarity in the name with the following: #6753

Although following Wordpress naming conventions, this describes better what the functionality should do. In any conflict with the other pull request, then change the name of this feature request whatever you want, until it describes the wanted functionality. If someone already asked for this feature, then please forgive me, I wasn't thorough to find it then.

So to understand, this question IS NOT ABOUT BLOCK NESTING!

Gutanberg blocks should have a feature to import another block as a base for modifications, like re-styling, adding or replacing functions and re-appearing under a new block in the editor. In functionality, this is exactly what a child theme does!

For example: I want to make a gallery block, where the images statically resembles the look of an Instagram API request in footer area. For easier understanding, this is the mockup:

Clipboard01

A well written gallery block already present in the core library, so why should I copy that code for my plugin for a slight re-styling? The easier solution would be to create a child block, have a slight CSS modification to put the images in one line until a responsive breakpoint, and maybe edit the code to limit maximum number of images able to upload in the gallery?

The advantages would be:

  • Child blocks will get continous development from the base blocks, like a child theme.
  • Less code clutter, more stable Wordpress installs.
  • Ability to separate modified child blocks from the base blocks in the block browser.

What is your proposed solution?

The implementation should be turned on with a simple switch, like:

<?php

/**
 * Plugin Name:     Gallery Block Child
 ...
 * Template:        core/gallery
 */
@karmatosed karmatosed added the Needs Technical Feedback Needs testing from a developer perspective. label Jan 4, 2022
@aristath
Copy link
Member

If all you need is CSS tweaks, then why not use the block-styles API?
You can easily add a new "variation" of the core-gallery block, and add all your styles in a custom class there using the register_block_style function.

@draganescu
Copy link
Contributor

With @aristath 's suggestion and your thumbs up @DJviolin may we close this issue?

@draganescu draganescu added [Status] Needs More Info Follow-up required in order to be actionable. [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. and removed Needs Technical Feedback Needs testing from a developer perspective. labels May 3, 2022
@DJviolin
Copy link
Author

DJviolin commented May 3, 2022

I didn't had the time to implement yet, so I will close it.

If the community would want such feature in the far future, then they can reopen it.

@DJviolin DJviolin closed this as completed May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Needs More Info Follow-up required in order to be actionable. [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed.
Projects
None yet
Development

No branches or pull requests

4 participants