From 3918074609c4dde04db03924363c56092f1af6ac Mon Sep 17 00:00:00 2001 From: Chrillaz Date: Thu, 29 Oct 2020 14:38:58 +0100 Subject: [PATCH] mobile view control patch --- blocks.php | 2 +- build/index.asset.php | 2 +- build/index.js | 2 +- readme.txt | 4 +-- src/blocks/accordion/edit.js | 13 ++++++- src/blocks/accordion/index.js | 4 +++ src/blocks/accordion/save.js | 6 ++-- src/blocks/bulletpoint/edit.js | 17 +++++++-- src/blocks/bulletpoint/index.js | 10 ++++-- src/blocks/google-map/edit.js | 13 ++++++- src/blocks/google-map/index.js | 6 +++- src/index.js | 64 ++++++++++++++++++--------------- 12 files changed, 100 insertions(+), 43 deletions(-) diff --git a/blocks.php b/blocks.php index e1917e1..6c8da8d 100644 --- a/blocks.php +++ b/blocks.php @@ -2,7 +2,7 @@ /** * Plugin Name: Noor Blocks * Description: Collection of custom blocks. - * Version: 1.1.2 + * Version: 1.1.3 * Author: Noor Digital Agency * Author URI: https://noordigital.com * Text Domain: blocks diff --git a/build/index.asset.php b/build/index.asset.php index af5b3a1..e7a6c69 100644 --- a/build/index.asset.php +++ b/build/index.asset.php @@ -1 +1 @@ - array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-polyfill'), 'version' => '436bdb2481a9e4dbe3e29c98d55f57bd'), 'accordion.js' => array('dependencies' => array('wp-polyfill'), 'version' => '954a5ccf99e04153addabfadf70be9cd')); \ No newline at end of file + array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-polyfill'), 'version' => '5864c2db1ff2d5760679b23e22a3bfb6'), 'accordion.js' => array('dependencies' => array('wp-polyfill'), 'version' => '954a5ccf99e04153addabfadf70be9cd')); \ No newline at end of file diff --git a/build/index.js b/build/index.js index e84d800..e862293 100644 --- a/build/index.js +++ b/build/index.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{18:function(e,t,n){}}]),function(e){function t(t){for(var o,a,l=t[0],i=t[1],s=t[2],b=0,d=[];be.length)&&(t=e.length);for(var n=0,o=new Array(t);ne.length)&&(t=e.length);for(var n=0,o=new Array(t);n + + + props.setAttributes({ mediaControl })} + /> +
@@ -73,6 +73,17 @@ export default function Edit( props ) { />} + + props.setAttributes({ mediaControl })} + /> + + { - const {color, backgroundColor, align} = attributes; + const {color, backgroundColor, align, mediaControl} = attributes; const colorClass = color != undefined ? getColorClassName( 'color', color ) : ''; const backgroundColorClass = backgroundColor != undefined ? getColorClassName('background-color', backgroundColor) : ''; + + const hide = mediaControl ? '' : 'on-media-hide'; return ( -
+
{attributes.useMedia && attributes.mediaId != 0 ? diff --git a/src/blocks/google-map/edit.js b/src/blocks/google-map/edit.js index 69fcf1f..083740d 100644 --- a/src/blocks/google-map/edit.js +++ b/src/blocks/google-map/edit.js @@ -11,7 +11,7 @@ export default function Edit ( props ) { const { attributes, setAttributes } = props; - const { width, height, zoom, address } = attributes; + const { width, height, zoom, address, mediaControl } = attributes; const getaddress = Object.values(address).filter(line => line != ''); @@ -75,6 +75,17 @@ export default function Edit ( props ) { onChange={country => setAttributes({ address: { ...address, country } })} /> + + + props.setAttributes({ mediaControl })} + /> +
diff --git a/src/blocks/google-map/index.js b/src/blocks/google-map/index.js index eb7f893..e770ef9 100644 --- a/src/blocks/google-map/index.js +++ b/src/blocks/google-map/index.js @@ -36,6 +36,10 @@ export const settings = { }, src: { type: 'string' + }, + mediaControl: { + type: 'boolean', + default: true } }, edit: Edit, @@ -43,7 +47,7 @@ export const settings = { const {width, height, src } = props.attributes; - props.className = 'noor-block-google-map'; + props.className = `noor-block-google-map ${props.attributes.mediaControl ? '' : 'on-media-hide'}`; return (
diff --git a/src/index.js b/src/index.js index 8dae670..a7f5f32 100644 --- a/src/index.js +++ b/src/index.js @@ -43,41 +43,49 @@ registerNoorBlocks(); const mediaQueryControl = (settings, name) => { - Object.assign(settings.attributes, { - mediaControl: { - type: 'boolean', - default: true - } - }); + if ( ! name.includes( 'noor' ) ) { + + Object.assign(settings.attributes, { + mediaControl: { + type: 'boolean', + default: true + } + }); + } return settings; } -const mediaControl = createHigherOrderComponent( BlockEdit => props => { - - return ( - - - - - - props.setAttributes({ mediaControl })} - /> - - - - ); +const mediaControl = createHigherOrderComponent( BlockEdit => props => { + + if ( ! props.name.includes( 'noor' ) ) { + + return ( + + + + + + props.setAttributes({ mediaControl })} + /> + + + + ); + } + + return }, 'mediaControl'); const mediaExtraProps = ( props, blockType, attributes ) => { - - if ( ! attributes.mediaControl ) { + + if ( ! attributes.mediaControl && ! blockType.name.includes('noor') ) { props.className = props.className + ' on-media-hide'; }