@wordpress/block-library
Version:
Block library for the WordPress editor.
52 lines (47 loc) • 1.83 kB
JavaScript
import { createElement, Fragment } from "@wordpress/element";
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { HorizontalRule } from '@wordpress/components';
import { useBlockProps, getColorClassName, __experimentalUseColorProps as useColorProps } from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import useDeprecatedOpacity from './use-deprecated-opacity';
export default function SeparatorEdit(_ref) {
var _colorProps$style, _style$color;
let {
attributes,
setAttributes
} = _ref;
const {
backgroundColor,
opacity,
style
} = attributes;
const colorProps = useColorProps(attributes);
const currentColor = colorProps === null || colorProps === void 0 ? void 0 : (_colorProps$style = colorProps.style) === null || _colorProps$style === void 0 ? void 0 : _colorProps$style.backgroundColor;
const hasCustomColor = !!(style !== null && style !== void 0 && (_style$color = style.color) !== null && _style$color !== void 0 && _style$color.background);
useDeprecatedOpacity(opacity, currentColor, setAttributes); // The dots styles uses text for the dots, to change those dots color is
// using color, not backgroundColor.
const colorClass = getColorClassName('color', backgroundColor);
const className = classnames({
'has-text-color': backgroundColor || currentColor,
[colorClass]: colorClass,
'has-css-opacity': opacity === 'css',
'has-alpha-channel-opacity': opacity === 'alpha-channel'
}, colorProps.className);
const styles = {
color: currentColor,
backgroundColor: currentColor
};
return createElement(Fragment, null, createElement(HorizontalRule, useBlockProps({
className,
style: hasCustomColor ? styles : undefined
})));
}
//# sourceMappingURL=edit.js.map