diff --git a/block/btn/block.js b/block/btn/block.js index 0049330c..55d360df 100644 --- a/block/btn/block.js +++ b/block/btn/block.js @@ -3,7 +3,7 @@ import classnames from 'classnames'; const { registerBlockType } = wp.blocks; -const { RichText, InspectorControls } = wp.editor; +const { RichText, InspectorControls, PanelColorSettings, ContrastChecker } = wp.editor; const { Button, PanelBody, SelectControl, TextControl } = wp.components; const { Fragment } = wp.element; const { __ } = wp.i18n; @@ -28,11 +28,17 @@ registerBlockType('snow-monkey-awesome-custom-blocks/btn', { modifier: { type: 'string', default: '' + }, + backgroundColor: { + type: 'string' + }, + textColor: { + type: 'string' } }, edit({ attributes, setAttributes }) { - const { content, url, target, modifier } = attributes; + const { content, url, target, modifier, backgroundColor, textColor } = attributes; const optionsTarget = [ { @@ -73,6 +79,14 @@ registerBlockType('snow-monkey-awesome-custom-blocks/btn', { setAttributes({ modifier: value }); }; + const onChangeBackgroundColor = (value) => { + setAttributes({ backgroundColor: value }); + }; + + const onChangeTextColor = (value) => { + setAttributes({ textColor: value }); + }; + return ( @@ -95,14 +109,35 @@ registerBlockType('snow-monkey-awesome-custom-blocks/btn', { options={ optionsModifier } /> + + - + @@ -111,11 +146,16 @@ registerBlockType('snow-monkey-awesome-custom-blocks/btn', { }, save({ attributes }) { - const { content, url, target, modifier } = attributes; + const { content, url, target, modifier, backgroundColor, textColor } = attributes; return ( - - + + { content }