import PropTypes from 'prop-types'; const { __ } = 'wp.i18n'; const { TextControl } = 'wp.components'; import { capitalize } from '../../../util/text'; const propTypes = { setAttributes: PropTypes.func.isRequired, attributeKey: PropTypes.string.isRequired, attributes: PropTypes.object, label: PropTypes.string, }; const defaultProps = { label: __('Block Margin'), }; const MarginControls = ({ setAttributes, attributeKey, attributes, label }) => { const margins = attributes[attributeKey]; const onMarginsChange = (value, position) => { setAttributes({ [attributeKey]: { ...margins, [position]: value, }, }); }; return (

{label}

{['top', 'right', 'bottom', 'left'].map(position => ( onMarginsChange(value, position)} /> ))}
); }; MarginControls.propTypes = propTypes; MarginControls.defaultProps = defaultProps; export default MarginControls;