Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Refactor cover background controls #18718
Disclaimer: since this is one of my first bigger PRs for Gutenberg, I approached this as a learning experience and hope that the changes are useful. Folks may want to take a different approach with this, which I absolutely understand :)
@paaljoachim asked me to take a look at #14744, and as I was looking around at related issues to understand the context, I came across #16479. In order to add some better background tools to the Group block, it seems like the first step would be refactoring the background controls out of the cover block into a place where they could be used more generically.
The goal of this PR is to refactor the background controls out of the cover block into a new
I think this is a good start to #16479 since it gives us a space to start thinking about how we should compose the background controls so that they can be easily used by other blocks. I expect a lot of this will change as we go forward, particularly with the design, but I hope this could let us abstract the changes behind this component so that other things which use it (for now, just the Cover block) will benefit from future changes.
Note that I did my best to avoid functionality changes. Most of the components and functions have been copy/pasted from the cover block's edit file and then wired together.
I took some inspiration from the new
Some things that still need consideration:
How has this been tested?
On my local gutenberg/docker environment, I confirmed that the cover block works exactly as it did before. The UI and controls are in the same places, and changes like gradient cover, images, focal point, etc. still work as expected.
Types of changes
Refactor, non-breaking change.
Hi Noah @noahtallen
How should we move this PR forward?
Thanks @paaljoachim. I fully expect my approach in this PR to be wrong, as it was my first try at a refactor in Gutenberg. I wasn't sure how to tackle just adding a background image to the block, but reusable background controls in general seems like a great way to accomplish it.
I bet a lot of stuff has changed in the past 4 months as well, so we might need to abandon this PR. At any rate, if folks have feedback about where to start when it comes to background controls, I'm happy to take a look.