Skip to content
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

Adding a reset to template columns for row layouts that use a multi-r… #629

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions includes/blocks/class-kadence-blocks-row-layout-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,23 @@ public function get_template_columns( $css, $columns, $layout, $inner_selector,
} else {
switch ( $layout ) {
case 'left-half':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr)';
break;
case 'right-half':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr)';
break;
case 'center-half':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr)';
break;
case 'center-wide':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'minmax(0, 1fr) minmax(0, 3fr) minmax(0, 1fr)';
break;
case 'center-exwide':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'minmax(0, 1fr) minmax(0, 6fr) minmax(0, 1fr)';
break;
case 'first-row':
Expand All @@ -204,12 +209,15 @@ public function get_template_columns( $css, $columns, $layout, $inner_selector,
$css->set_selector( $inner_selector );
break;
case 'two-grid':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'repeat(2, minmax(0, 1fr))';
break;
case 'row':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'minmax(0, 1fr)';
break;
default:
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'repeat(3, minmax(0, 1fr))';
break;
}
Expand All @@ -221,18 +229,23 @@ public function get_template_columns( $css, $columns, $layout, $inner_selector,
} else {
switch ( $layout ) {
case 'left-forty':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr)';
break;
case 'right-forty':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr)';
break;
case 'two-grid':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'repeat(2, minmax(0, 1fr))';
break;
case 'row':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'minmax(0, 1fr)';
break;
default:
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'repeat(4, minmax(0, 1fr))';
break;
}
Expand All @@ -256,15 +269,19 @@ public function get_template_columns( $css, $columns, $layout, $inner_selector,
$css->set_selector( $inner_selector );
break;
case 'two-grid':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'repeat(2, minmax(0, 1fr))';
break;
case 'three-grid':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'repeat(3, minmax(0, 1fr))';
break;
case 'row':
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'minmax(0, 1fr)';
break;
default:
$this->reset_grid_colum_for_template_columns( $css, $inner_selector );
$grid_layout = 'repeat(5, minmax(0, 1fr))';
break;
}
Expand Down Expand Up @@ -293,6 +310,16 @@ public function get_template_columns( $css, $columns, $layout, $inner_selector,
}
return $grid_layout;
}

/**
* A reset helper for the template columns
*/
public function reset_grid_colum_for_template_columns( $css, $inner_selector ) {
$css->set_selector( $inner_selector . ' > *:not(.added-for-specificity):not(.added-for-specificity)' );
$css->add_property( 'grid-column', 'initial' );
$css->set_selector( $inner_selector );
}

/**
* Builds CSS for block.
*
Expand Down
Loading