@gechiui/block-editor
Version:
41 lines (35 loc) • 805 B
JavaScript
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* GeChiUI dependencies
*/
import { Icon } from '@gechiui/components';
import { blockDefault } from '@gechiui/icons';
import { memo } from '@gechiui/element';
function BlockIcon( { icon, showColors = false, className } ) {
if ( icon?.src === 'block-default' ) {
icon = {
src: blockDefault,
};
}
const renderedIcon = <Icon icon={ icon && icon.src ? icon.src : icon } />;
const style = showColors
? {
backgroundColor: icon && icon.background,
color: icon && icon.foreground,
}
: {};
return (
<span
style={ style }
className={ classnames( 'block-editor-block-icon', className, {
'has-colors': showColors,
} ) }
>
{ renderedIcon }
</span>
);
}
export default memo( BlockIcon );