Skip to content

Commit

Permalink
Layout: Apply negative margin to full child blocks of custom padding (#…
Browse files Browse the repository at this point in the history
…60716)

Co-authored-by: richtabor <richtabor@git.wordpress.org>
Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
Co-authored-by: bph <bph@git.wordpress.org>
  • Loading branch information
4 people authored Apr 15, 2024
1 parent ee773ce commit 0469173
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,32 +292,32 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support
'declarations' => array( 'max-width' => 'none' ),
)
);
}

if ( isset( $block_spacing ) ) {
$block_spacing_values = gutenberg_style_engine_get_styles(
array(
'spacing' => $block_spacing,
)
);
if ( isset( $block_spacing ) ) {
$block_spacing_values = gutenberg_style_engine_get_styles(
array(
'spacing' => $block_spacing,
)
);

/*
* Handle negative margins for alignfull children of blocks with custom padding set.
* They're added separately because padding might only be set on one side.
*/
if ( isset( $block_spacing_values['declarations']['padding-right'] ) ) {
$padding_right = $block_spacing_values['declarations']['padding-right'];
$layout_styles[] = array(
'selector' => "$selector > .alignfull",
'declarations' => array( 'margin-right' => "calc($padding_right * -1)" ),
);
}
if ( isset( $block_spacing_values['declarations']['padding-left'] ) ) {
$padding_left = $block_spacing_values['declarations']['padding-left'];
$layout_styles[] = array(
'selector' => "$selector > .alignfull",
'declarations' => array( 'margin-left' => "calc($padding_left * -1)" ),
);
}
/*
* Handle negative margins for alignfull children of blocks with custom padding set.
* They're added separately because padding might only be set on one side.
*/
if ( isset( $block_spacing_values['declarations']['padding-right'] ) ) {
$padding_right = $block_spacing_values['declarations']['padding-right'];
$layout_styles[] = array(
'selector' => "$selector > .alignfull",
'declarations' => array( 'margin-right' => "calc($padding_right * -1)" ),
);
}
if ( isset( $block_spacing_values['declarations']['padding-left'] ) ) {
$padding_left = $block_spacing_values['declarations']['padding-left'];
$layout_styles[] = array(
'selector' => "$selector > .alignfull",
'declarations' => array( 'margin-left' => "calc($padding_left * -1)" ),
);
}
}

Expand Down

0 comments on commit 0469173

Please sign in to comment.