diff --git a/blocks/inspector-controls/base-control/index.js b/blocks/inspector-controls/base-control/index.js new file mode 100644 index 0000000000000..6d671320fb915 --- /dev/null +++ b/blocks/inspector-controls/base-control/index.js @@ -0,0 +1,20 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + +/** + * Internal dependencies + */ +import './style.scss'; + +function BaseControl( { id, label, className, children } ) { + return ( +
+ { label && } + { children } +
+ ); +} + +export default BaseControl; diff --git a/blocks/inspector-controls/base-control/style.scss b/blocks/inspector-controls/base-control/style.scss new file mode 100644 index 0000000000000..b09bb5814ac0e --- /dev/null +++ b/blocks/inspector-controls/base-control/style.scss @@ -0,0 +1,9 @@ +.blocks-base-control:not(:last-child) { + margin-bottom: 15px; +} + +.blocks-base-control__label { + display: block; + font-weight: 500; + margin-bottom: 5px; +} \ No newline at end of file diff --git a/blocks/inspector-controls/checkbox-control/index.js b/blocks/inspector-controls/checkbox-control/index.js new file mode 100644 index 0000000000000..857bd109512df --- /dev/null +++ b/blocks/inspector-controls/checkbox-control/index.js @@ -0,0 +1,34 @@ +/** + * WordPress dependencies + */ +import { withInstanceId } from 'components'; + +/** + * Internal dependencies + */ +import BaseControl from './../base-control'; +import './style.scss'; + +function CheckboxControl( { label, heading, checked, instanceId, onChange, ...props } ) { + const id = 'inspector-checkbox-control-' + instanceId; + const onChangeValue = ( event ) => onChange( event.target.value ); + + return ( + + + + ); +} + +export default withInstanceId( CheckboxControl ); diff --git a/blocks/inspector-controls/checkbox-control/style.scss b/blocks/inspector-controls/checkbox-control/style.scss new file mode 100644 index 0000000000000..cc072a2473e45 --- /dev/null +++ b/blocks/inspector-controls/checkbox-control/style.scss @@ -0,0 +1,3 @@ +.blocks-checkbox-control__input[type=checkbox] { + margin-right: 6px; +} \ No newline at end of file diff --git a/blocks/inspector-controls/radio-control/index.js b/blocks/inspector-controls/radio-control/index.js new file mode 100644 index 0000000000000..e7fc11022d173 --- /dev/null +++ b/blocks/inspector-controls/radio-control/index.js @@ -0,0 +1,39 @@ +/** + * WordPress dependencies + */ +import { withInstanceId } from 'components'; +import { isEmpty } from 'lodash'; + +/** + * Internal dependencies + */ +import BaseControl from './../base-control'; +import './style.scss'; + +function RadioControl( { label, selected, instanceId, onChange, options = [] } ) { + const id = 'inspector-radio-control-' + instanceId; + const onChangeValue = ( event ) => onChange( event.target.value ); + + return ! isEmpty( options ) && ( + + { options.map( ( option, index ) => +
+ + +
+ ) } +
+ ); +} + +export default withInstanceId( RadioControl ); diff --git a/blocks/inspector-controls/radio-control/style.scss b/blocks/inspector-controls/radio-control/style.scss new file mode 100644 index 0000000000000..9f11fd1c76f01 --- /dev/null +++ b/blocks/inspector-controls/radio-control/style.scss @@ -0,0 +1,13 @@ +.blocks-radio-control { + display: flex; + flex-direction: column; +} + +.blocks-radio-control__option:not(:last-child) { + margin-bottom: 4px; +} + +.blocks-radio-control__input[type=radio] { + margin-top: 0; + margin-right: 6px; +} \ No newline at end of file diff --git a/blocks/inspector-controls/range-control/index.js b/blocks/inspector-controls/range-control/index.js index a596513fdd9ca..b02221099aba2 100644 --- a/blocks/inspector-controls/range-control/index.js +++ b/blocks/inspector-controls/range-control/index.js @@ -6,17 +6,19 @@ import { withInstanceId } from 'components'; /** * Internal dependencies */ +import BaseControl from './../base-control'; import './style.scss'; function RangeControl( { label, value, instanceId, onChange, ...props } ) { const id = 'inspector-range-control-' + instanceId; return ( -
- - - { value } -
+ +
+ + { value } +
+
); } diff --git a/blocks/inspector-controls/range-control/style.scss b/blocks/inspector-controls/range-control/style.scss index 81b946ecd9393..af4fcd62796f3 100644 --- a/blocks/inspector-controls/range-control/style.scss +++ b/blocks/inspector-controls/range-control/style.scss @@ -1,9 +1,14 @@ .blocks-range-control { - margin-bottom: 10px; + display: flex; + justify-content: center; } -.blocks-range-control__label { - display: block; - font-weight: 500; - margin-bottom: 5px; +.blocks-range-control__input { + width: 100%; } + +.blocks-range-control__hint { + display: inline-block; + margin-left: 10px; + font-weight: 500; +} \ No newline at end of file diff --git a/blocks/inspector-controls/select-control/index.js b/blocks/inspector-controls/select-control/index.js new file mode 100644 index 0000000000000..61a1543a79290 --- /dev/null +++ b/blocks/inspector-controls/select-control/index.js @@ -0,0 +1,39 @@ +/** + * WordPress dependencies + */ +import { withInstanceId } from 'components'; +import { isEmpty } from 'lodash'; + +/** + * Internal dependencies + */ +import BaseControl from './../base-control'; +import './style.scss'; + +function SelectControl( { label, selected, instanceId, onBlur, options = [], ...props } ) { + const id = 'inspector-select-control-' + instanceId; + const onBlurValue = ( event ) => onBlur( event.target.value ); + + return ! isEmpty( options ) && ( + + + + ); +} + +export default withInstanceId( SelectControl ); diff --git a/blocks/inspector-controls/select-control/style.scss b/blocks/inspector-controls/select-control/style.scss new file mode 100644 index 0000000000000..fbfa090c76f20 --- /dev/null +++ b/blocks/inspector-controls/select-control/style.scss @@ -0,0 +1,3 @@ +.blocks-select-control__input { + width: 100%; +} \ No newline at end of file diff --git a/blocks/inspector-controls/text-control/index.js b/blocks/inspector-controls/text-control/index.js index 4294e20c321f8..2b9874dd03a30 100644 --- a/blocks/inspector-controls/text-control/index.js +++ b/blocks/inspector-controls/text-control/index.js @@ -6,6 +6,7 @@ import { withInstanceId } from 'components'; /** * Internal dependencies */ +import BaseControl from './../base-control'; import './style.scss'; function TextControl( { label, value, instanceId, onChange, type = 'text', ...props } ) { @@ -13,10 +14,9 @@ function TextControl( { label, value, instanceId, onChange, type = 'text', ...pr const onChangeValue = ( event ) => onChange( event.target.value ); return ( -
- + -
+ ); } diff --git a/blocks/inspector-controls/text-control/style.scss b/blocks/inspector-controls/text-control/style.scss index be49efd08ff5c..f363338fada1b 100644 --- a/blocks/inspector-controls/text-control/style.scss +++ b/blocks/inspector-controls/text-control/style.scss @@ -1,15 +1,4 @@ -.blocks-text-control { - margin-bottom: 10px; -} - -.blocks-text-control__label { - display: block; - font-weight: 500; - margin-bottom: 5px; -} - .blocks-text-control__input { width: 100%; - padding: 6px 10px; + padding: 6px 8px; } - diff --git a/blocks/inspector-controls/textarea-control/index.js b/blocks/inspector-controls/textarea-control/index.js new file mode 100644 index 0000000000000..3c01c2b0ba860 --- /dev/null +++ b/blocks/inspector-controls/textarea-control/index.js @@ -0,0 +1,25 @@ +/** + * WordPress dependencies + */ +import { withInstanceId } from 'components'; + +/** + * Internal dependencies + */ +import BaseControl from './../base-control'; +import './style.scss'; + +function TextareaControl( { label, value, instanceId, onChange, rows = 4, ...props } ) { + const id = 'inspector-textarea-control-' + instanceId; + const onChangeValue = ( event ) => onChange( event.target.value ); + + return ( + + + + ); +} + +export default withInstanceId( TextareaControl ); diff --git a/blocks/inspector-controls/textarea-control/style.scss b/blocks/inspector-controls/textarea-control/style.scss new file mode 100644 index 0000000000000..8a646f39b6dc0 --- /dev/null +++ b/blocks/inspector-controls/textarea-control/style.scss @@ -0,0 +1,4 @@ +.blocks-textarea-control__input { + width: 100%; + padding: 6px 8px; +} diff --git a/blocks/inspector-controls/toggle-control/index.js b/blocks/inspector-controls/toggle-control/index.js new file mode 100644 index 0000000000000..7d83704699443 --- /dev/null +++ b/blocks/inspector-controls/toggle-control/index.js @@ -0,0 +1,23 @@ +/** + * WordPress dependencies + */ +import { withInstanceId } from 'components'; +import Toggle from 'components/form-toggle'; + +/** + * Internal dependencies + */ +import BaseControl from './../base-control'; +import './style.scss'; + +function ToggleControl( { label, checked, instanceId, onChange } ) { + const id = 'inspector-toggle-control-' + instanceId; + + return ( + + + + ); +} + +export default withInstanceId( ToggleControl ); diff --git a/blocks/inspector-controls/toggle-control/style.scss b/blocks/inspector-controls/toggle-control/style.scss new file mode 100644 index 0000000000000..56823361911d8 --- /dev/null +++ b/blocks/inspector-controls/toggle-control/style.scss @@ -0,0 +1,4 @@ +.blocks-toggle-control { + display: flex; + justify-content: space-between; +} \ No newline at end of file diff --git a/blocks/library/text/index.js b/blocks/library/text/index.js index c2b29e03ba166..c111ac5e56f76 100644 --- a/blocks/library/text/index.js +++ b/blocks/library/text/index.js @@ -3,7 +3,6 @@ */ import { __ } from 'i18n'; import { Children, cloneElement } from 'element'; -import Toggle from 'components/form-toggle'; /** * Internal dependencies @@ -13,6 +12,7 @@ import AlignmentToolbar from '../../alignment-toolbar'; import BlockControls from '../../block-controls'; import Editable from '../../editable'; import InspectorControls from '../../inspector-controls'; +import ToggleControl from '../../inspector-controls/toggle-control'; const { children } = query; @@ -49,14 +49,11 @@ registerBlockType( 'core/text', { ), focus && ( -
- - -
+
),