Skip to content

Commit

Permalink
fixing issue with column styles and matching editor to frontend fro r…
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-c-woodard committed Dec 11, 2024
1 parent 9035e71 commit 41fbf1c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
8 changes: 7 additions & 1 deletion includes/blocks/class-kadence-blocks-table-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,13 @@ public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
if( !empty( $attributes['columnBackgrounds'] ) ) {
foreach( $attributes['columnBackgrounds'] as $index => $background ) {
if ( $background ) {
$css->set_selector( '.kb-table-container .kb-table' . esc_attr( $unique_id ) . ' td:nth-of-type(' . ( $index + 1 ) . '), .kb-table-container .kb-table' . esc_attr( $unique_id ) . ' th:nth-of-type(' . ( $index + 1 ) . ')' );
if( $attributes['isFirstColumnHeader'] ) {
$css->set_selector( '.kb-table-container .kb-table' . esc_attr( $unique_id ) . ' td:nth-of-type(' . ( $index ) . ')' );
} else {
$css->set_selector( '.kb-table-container .kb-table' . esc_attr( $unique_id ) . ' td:nth-of-type(' . ( $index + 1 ) . ')' );
}
$css->add_property( 'background-color', $css->render_color( $background ) );
$css->set_selector( '.kb-table-container .kb-table' . esc_attr( $unique_id ) . ' th:nth-of-type(' . ( $index + 1 ) . ')' );
$css->add_property( 'background-color', $css->render_color( $background ) );
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/blocks/table/children/row/backend-styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,15 @@ export default function BackendStyles(props) {

const css = new KadenceBlocksCSS();

css.set_selector(
`.kb-table-container .kb-table tr.kb-table-row${uniqueID}, .kb-table-container .kb-table tr.kb-table-row${uniqueID} th, .kb-table-container .kb-table tr.kb-table-row${uniqueID} td`
);
css.set_selector(`.kb-table-container .kb-table tr.kb-table-row${uniqueID}`);
if (previewMinHeight) {
css.add_property('height', previewMinHeight + minHeightType);
}
if (backgroundColor !== '') {
css.add_property('background-color', KadenceColorOutput(backgroundColor));
}

css.set_selector(
`.kb-table-container .kb-table tr.kb-table-row${uniqueID}:hover, .kb-table-container .kb-table tr.kb-table-row${uniqueID}:hover th, .kb-table-container .kb-table tr.kb-table-row${uniqueID}:hover td`
);
css.set_selector(`.kb-table-container .kb-table tr.kb-table-row${uniqueID}:hover`);
if (backgroundHoverColor !== '') {
css.add_property('background-color', KadenceColorOutput(backgroundHoverColor));
}
Expand Down
13 changes: 8 additions & 5 deletions src/blocks/table/components/backend-styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default function BackendStyles(props) {
tabletMargin,
mobileMargin,
marginType,
isFirstColumnHeader,
} = attributes;
const css = new KadenceBlocksCSS();

Expand Down Expand Up @@ -197,11 +198,13 @@ export default function BackendStyles(props) {
if (columnBackgrounds) {
columnBackgrounds.forEach((background, index) => {
if (background) {
css.set_selector(
`.kb-table${uniqueID} td:nth-of-type(${index + 1}), .kb-table${uniqueID} th:nth-of-type(${
index + 1
})`
);
if (isFirstColumnHeader) {
css.set_selector(`.kb-table${uniqueID} td:nth-of-type(${index})`);
} else {
css.set_selector(`.kb-table${uniqueID} td:nth-of-type(${index + 1})`);
}
css.add_property('background-color', KadenceColorOutput(background));
css.set_selector(`.kb-table${uniqueID} th:nth-of-type(${index + 1})`);
css.add_property('background-color', KadenceColorOutput(background));
}
});
Expand Down

0 comments on commit 41fbf1c

Please sign in to comment.