Skip to content

Commit

Permalink
V1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrillaz committed Nov 3, 2020
1 parent a61f1d5 commit 3a93dd1
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Noor Blocks
* Description: Collection of custom blocks.
* Version: 1.1.8
* Version: 1.2.0
* Author: Noor Digital Agency
* Author URI: https://noordigital.com
* Text Domain: blocks
Expand Down
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('index.js' => array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-polyfill'), 'version' => '3076feacda64bf6857bb4a359a36284c'), 'accordion.js' => array('dependencies' => array('wp-polyfill'), 'version' => 'f6dd97dfbf2ad4e550d221d31795fb15'));
<?php return array('index.js' => array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-polyfill'), 'version' => '78d406d7cc444e71318d17581caeb563'), 'accordion.js' => array('dependencies' => array('wp-polyfill'), 'version' => 'f6dd97dfbf2ad4e550d221d31795fb15'));
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors:
Tags: block
Requires at least: 5.3.2
Tested up to: 5.4.1
Stable tag: 1.1.8
Stable tag: 1.2.0
Requires PHP: 7.0.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -60,6 +60,10 @@ directory take precedence. For example, `/assets/screenshot-1.png` would win ove

1. imporoved on button icon control

* Patch 1.2.0

1. Functional controls

== Arbitrary section ==

You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated
Expand Down
57 changes: 32 additions & 25 deletions src/components/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,24 @@ export const ButtonIconControl = ({ attributes, setAttributes }) => {

const { className } = attributes;

const classList = className != undefined ? [...className.split( ' ' )] : [ `has-icon-${iconControlOptions[0]}`, 'has-right-icon'];
let classList = className != undefined
? [...className.split( ' ' )]
: [ `has-icon-${iconControlOptions[0]}`, 'has-right-icon'];

const hasAlign = boolean => boolean ? 'right' : 'left';

const [useIcon, setUse] = useState(
classList.some(name => name.includes('icon' ) )
);

const [alignIcon, setAlign] = useState(
hasAlign( classList.some(name => name.includes('has-right-icon') ) )
);

const [icon, setIcon] = useState(
iconControlOptions.filter( icon => classList.includes( `has-icon-${icon}` )).join('')
);

const [alignIcon, setAlign] = useState(
hasAlign( classList.some(name => name.includes('has-right-icon') ) )
)

const classes = () => classList.map(name => {

return name === 'has-right-icon' || name === 'has-left-icon'
Expand All @@ -73,34 +75,39 @@ export const ButtonIconControl = ({ attributes, setAttributes }) => {
: name;
}).join( ' ' );

setAttributes({ className: classes() });
setAttributes({ className: useIcon ? classes() : undefined });

return (
<PanelBody
title={ __( 'Inline Icon Control' ) }
initialOpen={ true }
>

<ToggleControl
label={ __( `Icon to ${alignIcon}`) }
checked={alignIcon === 'right' ? true : false}
onChange={() => {
setAlign( hasAlign( alignIcon !== 'right' ) )
// setAttributes({ className: classes() });
}}
<ToggleControl
label={__('Use inline icon')}
checked={useIcon}
onChange={() => setUse( ! useIcon )}
/>

<RadioGroup
label={__('Inline Icon')}
onClick={event => {
event.preventDefault();
setIcon( event.currentTarget.value )
// setAttributes({ className: classes() });
}}
options={iconControlOptions}
initialChecked={icon}
showIcons={true}
/>
{useIcon &&
<Fragment>
<ToggleControl
label={ __( `Icon to ${alignIcon}`) }
checked={alignIcon === 'right' ? true : false}
onChange={() => setAlign( hasAlign( alignIcon !== 'right' ) )}
/>

<RadioGroup
label={__('Inline Icon')}
onClick={event => {
event.preventDefault();
setIcon( event.currentTarget.value )
}}
options={iconControlOptions}
initialChecked={icon}
showIcons={true}
/>
</Fragment>
}
</PanelBody>
);
}
10 changes: 0 additions & 10 deletions src/filters/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ export const attributes = (settings, name) => {
});
}

if ( 'core/button' === name ) {

Object.assign(settings.attributes, {
useIcon: {
type: 'boolean',
default: true
}
});
}

if ( 'core/column' === name ) {

Object.assign(settings.attributes, {
Expand Down

0 comments on commit 3a93dd1

Please sign in to comment.