UNPKG

@wordpress/block-editor

Version:
40 lines (36 loc) 923 B
import { createElement } from "@wordpress/element"; /** * External dependencies */ import classnames from 'classnames'; /** * WordPress dependencies */ import { Icon } from '@wordpress/components'; import { blockDefault } from '@wordpress/icons'; export default function BlockIcon({ icon, showColors = false, className }) { var _icon; if (((_icon = icon) === null || _icon === void 0 ? void 0 : _icon.src) === 'block-default') { icon = { src: blockDefault }; } const renderedIcon = createElement(Icon, { icon: icon && icon.src ? icon.src : icon }); const style = showColors ? { backgroundColor: icon && icon.background, color: icon && icon.foreground } : {}; return createElement("span", { style: style, className: classnames('block-editor-block-icon', className, { 'has-colors': showColors }) }, renderedIcon); } //# sourceMappingURL=index.js.map