-
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 padding support to Group block #24966
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
"__experimentalColor": { | ||
"gradients": true, | ||
"linkColor": true | ||
} | ||
}, | ||
"__experimentalPadding": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ import { | |
InnerBlocks, | ||
__experimentalBlock as Block, | ||
} from '@wordpress/block-editor'; | ||
import { __experimentalBoxControl as BoxControl } from '@wordpress/components'; | ||
const { __Visualizer: BoxControlVisualizer } = BoxControl; | ||
|
||
function GroupEdit( { attributes, className, clientId } ) { | ||
const hasInnerBlocks = useSelect( | ||
|
@@ -20,6 +22,10 @@ function GroupEdit( { attributes, className, clientId } ) { | |
|
||
return ( | ||
<BlockWrapper className={ className }> | ||
<BoxControlVisualizer | ||
values={ attributes.style?.spacing?.padding } | ||
showValues={ attributes.style?.visualizers?.padding } | ||
/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can probably be absorbed by the hook and added automatically somehow. cc @ItsJonQ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ItsJonQ I'm not familiar with the attribute shape yet, can you clarify a bit what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be nice if it would be absorbed by the hook, otherwise we need to be more careful with any updates to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @youknowriad Sure! I can expand on this a bit. The visualizers need to show in 2 ways:
Right now, state for It works, but I'd prefer a more streamlined way of coordinating this state - Ideally without using the data store and relying on a Hope this helps! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'm a bit concerned about the use of an attribute for that state since it's not a persistent state. |
||
<InnerBlocks | ||
renderAppender={ | ||
hasInnerBlocks | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,6 @@ | |
*/ | ||
|
||
.wp-block-group { | ||
// Zero out the baseline margin that is set for every block in the editor. | ||
margin-top: 0; | ||
margin-bottom: 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is not needed with my change here https://github.com/WordPress/gutenberg/pull/24966/files#r481034215 |
||
|
||
// Ensure not rendering outside the element | ||
// as -1px causes overflow-x scrollbars | ||
|
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.
@jasmussen The idea here is that since we're defining the base margin above, we need to reset these margins for the first and last block of each container block.
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.
Without this, the padding is not applied properly in the group block (you'll notice an extra space on tthe editor)
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.
As can be seen in #24966 (comment), this isn't working for me. I have the following in my editor style:
I'm still sort of worried about this being an awfully specific style rule that could have consequences we can't imagine. I don't have a strong opinion, insofar as I appreciate you trying to handle this so I wouldn't have to manually go to the last paragraph and specify a zero margin. I suppose we can try it, and remove it if it has side effects.
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.
I'm afraid this had unintended consequences.
The above happens because every nesting container has a last child that's the appender:
Unless, apparently, an adjacent block has been selected:
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.
I guess that's because the appender div is the "last child" so the margin reset is not applied. I wonder why this empty div is rendered and whether we can remove it.
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.
In this PR, I remove the rules: #25527 — I honestly think it's for the best.
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.
I'll take a look but I think there's still value in the rules. So I'd like to see if we can find a better solution.