/** * WordPress dependencies */ import { Button, Flex, FlexItem, FlexBlock, Popover, ColorIndicator, ColorPicker, RangeControl } from '@wordpress/components'; import { withInstanceId } from '@wordpress/compose'; import { useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ import ResetButton from '../reset-btn'; import ButtonsGroupControl from '../buttons-group'; import { BOX_SHADOW_POSITION } from '../../constants'; import ResLabelControl from '../res-label-control'; const BoxShadowControl = ({ instanceId, label, controlName, objAttrs }) => { const [boxshadowPanel, setBoxshadowPanel] = useState(false); const [colorpanel, setColorpanel] = useState(false); const colors = wp.data.select('core/editor').getEditorSettings().colors; const id = `boxshadow-control-${instanceId}`; const { attributes, setAttributes } = objAttrs; const { [`${controlName}BoxShadowPosition`]: boxShadowPosition = 'outset', [`${controlName}BoxShadowColor`]: boxShadowColor, [`${controlName}BoxShadowHorizontal`]: boxShadowHorizontal, [`${controlName}BoxShadowVertical`]: boxShadowVertical, [`${controlName}BoxShadowBlur`]: boxShadowBlur, [`${controlName}BoxShadowSpread`]: boxShadowSpread } = attributes; return (
{colorpanel && ( setColorpanel(false)} position="bottom center" offset={5}> setAttributes({ [`${controlName}BoxShadowColor`]: value.hex }) } disableAlpha={false} />
{colors && colors.map((paletteColor, index) => { return ( setAttributes({ [`${controlName}BoxShadowColor`]: paletteColor.color }) } /> ); })}
)}
setAttributes({ [`${controlName}BoxShadowHorizontal`]: '' }) } value={boxShadowHorizontal} > setAttributes({ [`${controlName}BoxShadowHorizontal`]: data }) } min={-100} max={100} />
setAttributes({ [`${controlName}BoxShadowVertical`]: '' }) } value={boxShadowVertical} > setAttributes({ [`${controlName}BoxShadowVertical`]: data }) } min={-100} max={100} />
setAttributes({ [`${controlName}BoxShadowBlur`]: '' }) } value={boxShadowBlur} > setAttributes({ [`${controlName}BoxShadowBlur`]: data }) } min={0} max={100} />
setAttributes({ [`${controlName}BoxShadowSpread`]: '' }) } value={boxShadowSpread} > setAttributes({ [`${controlName}BoxShadowSpread`]: data }) } min={0} max={100} /> )} ); }; export default withInstanceId(BoxShadowControl);