UNPKG

@wordpress/block-editor

Version:
53 lines (47 loc) 1.29 kB
import { createElement } from "@wordpress/element"; /** * WordPress dependencies */ import { RangeControl } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ import { cleanEmptyObject } from './utils'; const MIN_BORDER_WIDTH = 0; const MAX_BORDER_WIDTH = 50; /** * Inspector control for configuring border width property. * * @param {Object} props Block properties. * @return {WPElement} Border width edit element. */ export const BorderWidthEdit = props => { var _style$border; const { attributes: { style }, setAttributes } = props; const onChange = newWidth => { const newStyle = { ...style, border: { ...(style === null || style === void 0 ? void 0 : style.border), width: newWidth } }; setAttributes({ style: cleanEmptyObject(newStyle) }); }; return createElement(RangeControl, { value: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.width, label: __('Border width'), min: MIN_BORDER_WIDTH, max: MAX_BORDER_WIDTH, initialPosition: 0, allowReset: true, onChange: onChange }); }; //# sourceMappingURL=border-width.js.map