-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 vertical alignment to blocks using flex control #40013
Conversation
Size Change: +2.83 kB (0%) Total Size: 1.22 MB
ℹ️ View Unchanged
|
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 feature
Thanks for the update, this looking better code wise, let's try to get some reviews on the design/behavior aspect. |
Doesn't seem to be working for me on a row block using the theme Remote (https://wordpress.org/themes/remote/) |
@youknowriad there are still some adjustments to do in the |
Nice, thanks for the PR, took a quick spin playing around with the vertical toolbar alignment controls: High level, this will be a very useful feature to have. It also feels worthwhile to have a button present in the block toolbar as it's valuable. As shown in the GIF, I couldn't get the alignment to actually work — I tested a paragraph and an imagea, and the paragraph kept vertically centered. Did I do anything wrong? Some thoughts:
Finally, the Layout panel likely showing horizontal alignment but not vertical stands out as a little uncanny. It would be nice to find a design that could accommodate both of these. This is an area where Figma might be on to something, as it unifies both horizontal and vertical alignments into a single unified panel: This is not unlike what we already have for the Cover block: In other words, there's an opportunity there to simplify. The larger question is whether that needs to block this PR. Probably not? |
@jasmussen @MaggieCabrera with d6c9253 you should be able to make it works. |
@@ -113,9 +119,11 @@ export default { | |||
const flexWrap = flexWrapOptions.includes( layout.flexWrap ) | |||
? layout.flexWrap | |||
: 'wrap'; | |||
const verticalAlignment = | |||
verticalAlignmentMap[ layout.verticalAlignment ]; |
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.
You need to add a fallback to previous center
value.
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.
Also the respective default for vertical orientation was the browser default so there was no visual issue, but in this case the center
is not the default and we need to make the button active probably.
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.
Also the respective default for vertical orientation was the browser default so there was no visual issue, but in this
case the center is not the default and we need to make the button active probably.
I didn't really understand this part, could you please explain me in detail?
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.
It seems we just need this change. Disregard my mention to browser defaults, because code might have changed here 😄 .
The point was that the controls should match the default/fallback value you added.
Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com>
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 @JustinyAhin, thank you for working on this one! ❤️ 🎉
The code looks good and makes sense.
Tested it and works as advertised. 👍
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.
value: 'flex-end', | ||
label: __( 'Align items bottom' ), | ||
}, | ||
]; |
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 think these options need to be replicated in lib/block-supports/layout.php, similar to how the $justify_content_options
array works. For example, by adding a vertical alignment options array:
$vertical_alignment_options = array(
'top' => 'flex-start',
'center' => 'center',
'bottom' => 'flex-end'
);
And then using these options, with $layout['verticalAlignment']
, around line 111, inside the $layout_orientation
check:
if ( ! empty( $layout['verticalAlignment'] ) && array_key_exists( $layout['verticalAlignment'], $vertical_alignment_options ) ) {
$style .= "align-items: {$vertical_alignment_options[ $layout['verticalAlignment'] ]};";
} else {
$style .= 'align-items: center;';
}
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 @mikachan.
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.
Those changes look good to me, this is working great on the front end now as well 🎉
What is the expected result for the navigation block which uses the flex control? I would like to be able to align the text items with the top of the logo, for example. https://user-images.githubusercontent.com/7422055/162396948-9551db45-e9c6-4a21-a668-bf01ae7a4ada.mp4 |
Buttons work well: https://user-images.githubusercontent.com/7422055/162398248-1e95c97b-d6cf-4def-bfee-f8235f6ed40d.mp4 |
Query pagination, comment query pagination -Works in the editor and front. |
I added a condition that will only render the control when using the horizontal alignment, and implemented a new |
Fixes #38498
What?
This PR adds a new block control for vertical alignment to the blocks that use flex control.
Why?
See #38498
How?
This adds a new
verticalAlignment
(gutenberg/packages/block-editor/src/components/block-vertical-alignment-control/index.js
Line 17 in 190a207
align-items
styles.Testing Instructions
height
property from the browser inspector)