Skip to content

Commit

Permalink
KAD-3933 updated row gap property to inherit
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbert-hernandez committed Jan 3, 2025
1 parent 87a98d0 commit 3e32522
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
10 changes: 1 addition & 9 deletions includes/blocks/class-kadence-blocks-row-layout-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,15 +566,7 @@ public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
}
$css->set_media_state( 'desktop' );
}
// Update $attributes if there are custom gaps that need to be inherited.
if ( ! empty( $attributes['columnGutter'] ) ) {
if ( empty( $attributes['tabletGutter'] ) ) {
$attributes['tabletGutter'] = $attributes['columnGutter'];
}
if ( empty( $attributes['mobileGutter'] ) ) {
$attributes['mobileGutter'] = $attributes['tabletGutter'];
}
}

//Tablet layout
if ( empty( $attributes['tabletLayout'] ) && ! empty( $css->render_row_gap_property( $attributes, array( 'columnGutter', 'tabletGutter', 'mobileGutter' ), 'tablet', 'customGutter', 'gutterType' ) ) ) {
//no tablet layout, but we have a tablet guttter width, so render the inherited column layout from desktop, potentially with custom widths.
Expand Down
20 changes: 17 additions & 3 deletions includes/class-kadence-blocks-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -1372,10 +1372,9 @@ public function render_row_gap( $attributes, $name = array( 'gap', 'tabletGap',
$this->set_media_state( 'desktop' );
}
/**
* Generates the shadow output.
* Generates the gutter gap output.
*
* @param array $shadow an array of shadow settings.
* @return string
*/
public function render_row_gap_property( $attributes, $name = array( 'gap', 'tabletGap', 'mobileGap' ), $device = 'desktop', $custom = '', $unit_name = 'gapUnit' ) {
if ( empty( $attributes ) || empty( $name ) ) {
Expand All @@ -1385,6 +1384,21 @@ public function render_row_gap_property( $attributes, $name = array( 'gap', 'tab
return '';
}
$unit = ! empty( $attributes[ $unit_name ] ) ? $attributes[ $unit_name ] : 'px';
// inherit tablet and mobile values
if ( is_array( $name ) && ! empty( $attributes[ $name[0] ] ) ) {
if ( empty( $attributes[ $name[1] ] ) ) {
$attributes[ $name[1] ] = $attributes[ $name[0] ];
}
if ( empty( $attributes[ $name[2] ] ) ) {
$attributes[ $name[2] ] = $attributes[ $name[1] ];
}
if ( $attributes[ $name[1] ] === 'custom' && empty( $attributes[ $custom ][1] ) ) {
$attributes[ $custom ][1] = $attributes[ $custom ][0];
}
if ( $attributes[ $name[2] ] === 'custom' && empty( $attributes[ $custom ][2] ) ) {
$attributes[ $custom ][2] = $attributes[ $custom ][1];
}
}
switch ( $device ) {
case 'tablet':
if ( ! empty( $attributes[ $name[1] ] ) ) {
Expand Down

0 comments on commit 3e32522

Please sign in to comment.