UNPKG

@wordpress/block-editor

Version:
48 lines (44 loc) 1.19 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import { createElement } from "@wordpress/element"; /** * External dependencies */ import { View } from 'react-native'; /** * WordPress dependencies */ import { Icon } from '@wordpress/components'; import { blockDefault } from '@wordpress/icons'; import { usePreferredColorSchemeStyle } from '@wordpress/compose'; /** * Internal dependencies */ import styles from './style.scss'; export function BlockIcon({ icon, fill, size, showColors = false }) { if (icon?.src === 'block-default') { icon = { src: blockDefault }; } const defaultFill = usePreferredColorSchemeStyle(styles.iconPlaceholder, styles.iconPlaceholderDark)?.fill; const iconForeground = showColors ? icon?.foreground : undefined; const renderedIcon = createElement(Icon, _extends({ icon: icon && icon.src ? icon.src : icon, fill: fill || iconForeground || defaultFill }, size && { size })); const style = showColors ? { backgroundColor: icon && icon.background } : {}; return createElement(View, { style: style }, renderedIcon); } export default BlockIcon; //# sourceMappingURL=index.native.js.map