@wordpress/block-editor
Version:
34 lines (33 loc) • 977 B
JavaScript
// packages/block-editor/src/components/block-icon/index.js
import clsx from "clsx";
import { Icon } from "@wordpress/components";
import { blockDefault } from "@wordpress/icons";
import { memo } from "@wordpress/element";
import { jsx } from "react/jsx-runtime";
function BlockIcon({ icon, showColors = false, className, context }) {
if (icon?.src === "block-default") {
icon = {
src: blockDefault
};
}
const renderedIcon = /* @__PURE__ */ jsx(Icon, { icon: icon && icon.src ? icon.src : icon, context });
const style = showColors ? {
backgroundColor: icon && icon.background,
color: icon && icon.foreground
} : {};
return /* @__PURE__ */ jsx(
"span",
{
style,
className: clsx("block-editor-block-icon", className, {
"has-colors": showColors
}),
children: renderedIcon
}
);
}
var block_icon_default = memo(BlockIcon);
export {
block_icon_default as default
};
//# sourceMappingURL=index.js.map