diff --git a/src/blocks/blocks/circle-counter/inspector.js b/src/blocks/blocks/circle-counter/inspector.js index 93d14132f..3cdccbd11 100644 --- a/src/blocks/blocks/circle-counter/inspector.js +++ b/src/blocks/blocks/circle-counter/inspector.js @@ -1,20 +1,35 @@ +/** + * External dependencies + */ +import { clamp } from 'lodash'; + /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { clamp } from 'lodash'; import { - __experimentalColorGradientControl as ColorGradientControl, - InspectorControls + InspectorControls, + PanelColorSettings } from '@wordpress/block-editor'; import { PanelBody, RangeControl, - SelectControl + SelectControl, + TextControl, + ToggleControl, + __experimentalToggleGroupControl as ToggleGroupControl, + __experimentalToggleGroupControlOption as ToggleGroupControlOption } from '@wordpress/components'; +import { Fragment, useState } from '@wordpress/element'; + +/** + * Internal dependencies +*/ +import { InspectorHeader } from '../../components'; +import { useTabSwitch } from '../../helpers/block-utility'; /** * @@ -25,6 +40,9 @@ const Inspector = ({ attributes, setAttributes }) => { + + const [ tab, setTab ] = useTabSwitch( attributes.id, 'settings' ); + const onPercentageChange = value => { if ( value === undefined ) { return; @@ -44,102 +62,152 @@ const Inspector = ({ return ( - - - - - - setAttributes({ titleStyle }) } - /> - - - - setAttributes({ height }) } - min={ 20 } - max={ 240 } - /> - - setAttributes({ strokeWidth }) } - initialPosition={ 10 } - min={ 0 } - max={ 20 } - /> - - setAttributes({ fontSizeTitle }) } - initialPosition={ 37 } - min={ 0 } - max={ 100 } - /> - - setAttributes({ fontSizePercent }) } - initialPosition={ 27 } - min={ 0 } - max={ 80 } - /> - - { ( 'hide' !== attributes.titleStyle ) && ( - setAttributes({ titleColor }) } - /> - ) } - - setAttributes({ progressColor }) } - /> - - setAttributes({ backgroundColor }) } - /> - + + +
+ { + 'settings' === tab && ( + + + setAttributes({ title }) } + /> + + + + ) + } + { + 'style' === tab && ( + + + setAttributes({ titleStyle: 'hide' !== attributes.titleStyle ? 'hide' : 'default' }) } + /> + + { 'hide' !== attributes.titleStyle && ( + setAttributes({ titleStyle }) } + isBlock + > + + + + )} + + setAttributes({ titleColor }), + label: __( 'Title Color', 'otter-blocks' ) + }, + { + value: attributes.progressColor, + onChange: progressColor => setAttributes({ progressColor }), + label: __( 'Progress Color', 'otter-blocks' ) + }, + { + value: attributes.backgroundColor, + onChange: backgroundColor => setAttributes({ backgroundColor }), + label: __( 'Background Color', 'otter-blocks' ) + } + ] } + /> + + setAttributes({ height }) } + min={ 20 } + max={ 240 } + /> + + setAttributes({ strokeWidth }) } + initialPosition={ 10 } + min={ 0 } + max={ 20 } + /> + + + + + setAttributes({ fontSizeTitle }) } + initialPosition={ 37 } + min={ 0 } + max={ 100 } + /> + + setAttributes({ fontSizePercent }) } + initialPosition={ 27 } + min={ 0 } + max={ 80 } + /> + + + + + ) + } +
); }; diff --git a/src/blocks/blocks/progress-bar/inspector.js b/src/blocks/blocks/progress-bar/inspector.js index 211115bf1..4f97894f7 100644 --- a/src/blocks/blocks/progress-bar/inspector.js +++ b/src/blocks/blocks/progress-bar/inspector.js @@ -1,9 +1,13 @@ +/** + * External dependencies + */ +import { clamp } from 'lodash'; + /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { clamp } from 'lodash'; import { InspectorControls, @@ -18,6 +22,14 @@ import { TextControl, FontSizePicker } from '@wordpress/components'; +import { Fragment, useState } from '@wordpress/element'; + +/** + * Internal dependencies +*/ +import { InspectorHeader } from '../../components'; +import { useTabSwitch } from '../../helpers/block-utility'; + const defaultFontSizes = [ { @@ -54,6 +66,9 @@ const Inspector = ({ heightMode, setHeightMode }) => { + + const [ tab, setTab ] = useTabSwitch( attributes.id, 'settings' ); + const onPercentageChange = value => { if ( value === undefined ) { return ; @@ -83,137 +98,163 @@ const Inspector = ({ return ( - - setAttributes({ title }) } - /> - - - - - - - - setAttributes({ titleColor }), - label: __( 'Title', 'otter-blocks' ), - isShownByDefault: false - }, - { - value: attributes.barBackgroundColor, - onChange: barBackgroundColor => setAttributes({ barBackgroundColor }), - label: __( 'Progress', 'otter-blocks' ), - isShownByDefault: false - }, + setAttributes({ percentageColor }), - label: __( 'Percentage', 'otter-blocks' ), - isShownByDefault: false + label: __( 'Settings', 'otter-blocks' ), + value: 'settings' }, { - value: attributes.backgroundColor, - onChange: backgroundColor => setAttributes({ backgroundColor }), - label: __( 'Background', 'otter-blocks' ), - isShownByDefault: false + label: __( 'Style', 'otter-blocks' ), + value: 'style' } - ] } - > - - - - - { 30 <= attributes.height && ( - setAttributes({ titleStyle }) } - /> - ) } - - - - - - setAttributes({ borderRadius }) } - step={ 0.1 } - initialPosition={ 5 } - min={ 0 } - max={ 35 } - /> + ]} + onChange={ setTab } + /> +
{ - ( ( 'outer' === attributes.titleStyle ) || ( 'tooltip' === attributes.percentagePosition && 'outer' === attributes.percentagePosition ) ) && ( - - setAttributes({ titleFontSize }) } + setAttributes({ title }) } + /> + + - + + ) + } + { + 'style' === tab && ( + + + + + { 30 <= attributes.height && ( + setAttributes({ titleStyle }) } + /> + ) } + + + + { + ( ( 'outer' === attributes.titleStyle ) || ( 'tooltip' === attributes.percentagePosition && 'outer' === attributes.percentagePosition ) ) && ( + + setAttributes({ titleFontSize }) } + /> + + ) + } + + setAttributes({ titleColor }), + label: __( 'Title', 'otter-blocks' ) + }, + { + value: attributes.barBackgroundColor, + onChange: barBackgroundColor => setAttributes({ barBackgroundColor }), + label: __( 'Progress', 'otter-blocks' ) + }, + { + value: attributes.percentageColor, + onChange: percentageColor => setAttributes({ percentageColor }), + label: __( 'Percentage', 'otter-blocks' ) + }, + { + value: attributes.backgroundColor, + onChange: backgroundColor => setAttributes({ backgroundColor }), + label: __( 'Background', 'otter-blocks' ) + } + ] } + > + + + + + + + + setAttributes({ borderRadius }) } + step={ 0.1 } + initialPosition={ 5 } + min={ 0 } + max={ 35 } + /> + + ) } +
-
); };