Skip to content

Commit

Permalink
Merge pull request #1082 from Codeinwp/fix/section-inherit-view-values
Browse files Browse the repository at this point in the history
Fix Section responsive inheritance
  • Loading branch information
HardeepAsrani authored Aug 4, 2022
2 parents 30571f7 + 2c02f4c commit 17f51e2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
4 changes: 4 additions & 0 deletions inc/class-pro.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ public static function get_docs_url() {
public static function should_show_upsell() {
$show_upsell = false;

if ( defined( 'OTTER_PRO_VERSION' ) ) {
return $show_upsell;
}

$installed = get_option( 'otter_blocks_install' );
$notifications = get_option( 'themeisle_blocks_settings_notifications', array() );

Expand Down
21 changes: 12 additions & 9 deletions src/blocks/blocks/section/column/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ import ResponsiveControl from '../../../components/responsive-control/index.js';
import BackgroundSelectorControl from '../../../components/background-selector-control/index.js';
import ControlPanelControl from '../../../components/control-panel-control/index.js';
import SyncControl from '../../../components/sync-control/index.js';
import { isNullObject } from '../../../helpers/helper-functions.js';
import {
isNullObject,
removeBoxDefaultValues
} from '../../../helpers/helper-functions.js';

/**
*
Expand Down Expand Up @@ -94,9 +97,9 @@ const Inspector = ({
case 'Desktop':
return getValue( 'padding' );
case 'Tablet':
return merge( getValue( 'padding' ), getValue( 'paddingTablet' ) );
return merge({ ...getValue( 'padding' ) }, getValue( 'paddingTablet' ) );
case 'Mobile':
return merge( getValue( 'padding' ), getValue( 'paddingTablet' ), getValue( 'paddingMobile' ) );
return merge({ ...getValue( 'padding' ) }, getValue( 'paddingTablet' ), getValue( 'paddingMobile' ) );
default:
return undefined;
}
Expand All @@ -111,9 +114,9 @@ const Inspector = ({
case 'Desktop':
return setAttributes({ padding: value });
case 'Tablet':
return setAttributes({ paddingTablet: value });
return setAttributes({ paddingTablet: removeBoxDefaultValues( value, attributes.padding ) });
case 'Mobile':
return setAttributes({ paddingMobile: value });
return setAttributes({ paddingMobile: removeBoxDefaultValues( value, { ...attributes.padding, ...attributes.paddingTablet }) });
default:
return undefined;
}
Expand All @@ -137,9 +140,9 @@ const Inspector = ({
case 'Desktop':
return getValue( 'margin' );
case 'Tablet':
return merge( getValue( 'margin' ), getValue( 'marginTablet' ) );
return merge({ ...getValue( 'margin' ) }, getValue( 'marginTablet' ) );
case 'Mobile':
return merge( getValue( 'margin' ), getValue( 'marginTablet' ), getValue( 'marginMobile' ) );
return merge({ ...getValue( 'margin' ) }, getValue( 'marginTablet' ), getValue( 'marginMobile' ) );
default:
return undefined;
}
Expand All @@ -154,9 +157,9 @@ const Inspector = ({
case 'Desktop':
return setAttributes({ margin: value });
case 'Tablet':
return setAttributes({ marginTablet: value });
return setAttributes({ marginTablet: removeBoxDefaultValues( value, attributes.margin ) });
case 'Mobile':
return setAttributes({ marginMobile: value });
return setAttributes({ marginMobile: removeBoxDefaultValues( value, { ...attributes.margin, ...attributes.marginTablet }) });
default:
return undefined;
}
Expand Down
23 changes: 12 additions & 11 deletions src/blocks/blocks/section/columns/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ import ControlPanelControl from '../../../components/control-panel-control/index
import HTMLAnchorControl from '../../../components/html-anchor-control/index.js';
import BackgroundSelectorControl from '../../../components/background-selector-control/index.js';
import SyncControl from '../../../components/sync-control/index.js';
import { isNullObject } from '../../../helpers/helper-functions.js';
import {
isNullObject,
removeBoxDefaultValues
} from '../../../helpers/helper-functions.js';
import ToogleGroupControl from '../../../components/toogle-group-control/index.js';

/**
Expand Down Expand Up @@ -131,9 +134,9 @@ const Inspector = ({
case 'Desktop':
return getValue( 'padding' );
case 'Tablet':
return merge( getValue( 'padding' ), getValue( 'paddingTablet' ) );
return merge({ ...getValue( 'padding' ) }, getValue( 'paddingTablet' ) );
case 'Mobile':
return merge( getValue( 'padding' ), getValue( 'paddingTablet' ), getValue( 'paddingMobile' ) ) ;
return merge({ ...getValue( 'padding' ) }, getValue( 'paddingTablet' ), getValue( 'paddingMobile' ) ) ;
default:
return undefined;
}
Expand All @@ -148,9 +151,9 @@ const Inspector = ({
case 'Desktop':
return setAttributes({ padding: value });
case 'Tablet':
return setAttributes({ paddingTablet: value });
return setAttributes({ paddingTablet: removeBoxDefaultValues( value, attributes.padding ) });
case 'Mobile':
return setAttributes({ paddingMobile: value });
return setAttributes({ paddingMobile: removeBoxDefaultValues( value, { ...attributes.padding, ...attributes.paddingTablet }) });
default:
return undefined;
}
Expand All @@ -174,9 +177,9 @@ const Inspector = ({
case 'Desktop':
return getValue( 'margin' );
case 'Tablet':
return merge( getValue( 'margin' ), getValue( 'marginTablet' ) );
return merge({ ...getValue( 'margin' ) }, getValue( 'marginTablet' ) );
case 'Mobile':
return merge( getValue( 'margin' ), getValue( 'marginTablet' ), getValue( 'marginMobile' ) );
return merge({ ...getValue( 'margin' ) }, getValue( 'marginTablet' ), getValue( 'marginMobile' ) );
default:
return undefined;
}
Expand All @@ -187,8 +190,6 @@ const Inspector = ({
value = undefined;
}

console.log( value );

if ( 'object' === typeof value ) {
value = Object.fromEntries( Object.entries( value ).filter( ([ _, v ]) => null !== v ) );
}
Expand All @@ -197,9 +198,9 @@ const Inspector = ({
case 'Desktop':
return setAttributes({ margin: value });
case 'Tablet':
return setAttributes({ marginTablet: value });
return setAttributes({ marginTablet: removeBoxDefaultValues( value, attributes.margin ) });
case 'Mobile':
return setAttributes({ marginMobile: value });
return setAttributes({ marginMobile: removeBoxDefaultValues( value, { ...attributes.margin, ...attributes.marginTablet }) });
default:
return undefined;
}
Expand Down

0 comments on commit 17f51e2

Please sign in to comment.