-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 transform for group block to cover block. #30890
Add transform for group block to cover block. #30890
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @getsource, really appreciate it!
I personally believe though that this change will produce more confusion than being an enhancement, and involves opinionated style changes as you already expressed your concerns.
I'll comment on the issue as well, but this functionality doesn't seem to work well. Maybe by having extra checks for having an Image
block in group's InnerBlocks and use that as the Cover's background 🤔 ? Even that would need more changes since the isMatch
from transforms API
would need to be extended to provide the innerBlocks
as well and not only the attributes
.
Reference: https://developer.wordpress.org/block-editor/reference-guides/block-api/block-transforms/#block
29039e8
to
ed9cef1
Compare
@ntsekouras Updated this to only offer transformation when an existing background color or gradient is available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for following this @getsource - nice work 💯
I've left a comment and then is ready to land.
blocks: [ 'core/group' ], | ||
isMatch: ( { backgroundColor, gradient, style } ) => { | ||
/* | ||
* Make sure the group has a background, since if the cover block is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a rewording here would be good - something like:
Make this transformation available only if the Group has background or gradient set, because otherwise
Cover
block displays a Placeholder. This helps us avoid arbitrary decisions about the Cover block's background and user confusion about the existence of previous content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in the most recent commit.
ed9cef1
to
c62159a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for all the confusion here @getsource , but this is the final comment and this will be ready to land 😄
- Copies inner blocks. - Uses existing background color or gradient if it's available. Otherwise, defaults to a white background to avoid prompt for image/color.
c62159a
to
92125d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! 💯
Thanks so much! |
Description
Otherwise, defaults to a white background to avoid prompt for image/color.Initial review props @Mamaduka
Closes: #30445
(edit: removed background default color due to feedback)
How has this been tested?
Tested manually in
wp-env
, and with existing automated tests withnpm run test
.Screenshots
Types of changes
Enhancement.
Adds ability to transform a group block into a cover block, maintaining existing background color or gradient.
Checklist:
*.native.js
files for terms that need renaming or removal).