@wordpress/block-library
Version:
Block library for the WordPress editor.
32 lines (31 loc) • 1.44 kB
JavaScript
import clsx from "clsx";
import { __experimentalUseBorderProps, __experimentalUseGradient, __experimentalUseMultipleOriginColorsAndGradients, withColors } from "@wordpress/block-editor";
import { compose } from "@wordpress/compose";
import { dimRatioToClass } from "./utils.mjs";
import { jsx } from "react/jsx-runtime";
// packages/block-library/src/post-featured-image/overlay.jsx
const Overlay = ({ attributes, overlayColor }) => {
const { dimRatio } = attributes;
const { gradientClass, gradientValue } = __experimentalUseGradient();
const colorGradientSettings = __experimentalUseMultipleOriginColorsAndGradients();
const borderProps = __experimentalUseBorderProps(attributes);
const overlayStyles = {
backgroundColor: overlayColor.color,
backgroundImage: gradientValue,
...borderProps.style
};
if (!colorGradientSettings.hasColorsOrGradients || !dimRatio) return null;
return /* @__PURE__ */ jsx("span", {
"aria-hidden": "true",
className: clsx("wp-block-post-featured-image__overlay", dimRatioToClass(dimRatio), {
[overlayColor.class]: overlayColor.class,
"has-background-dim": dimRatio !== void 0,
"has-background-gradient": gradientValue,
[gradientClass]: gradientClass
}, borderProps.className),
style: overlayStyles
});
};
var overlay_default = compose([withColors({ overlayColor: "background-color" })])(Overlay);
export { overlay_default as default };
//# sourceMappingURL=overlay.mjs.map