2020-01-31 18:20:33 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { cloneElement, isValidElement } from '@wordpress/element';
|
|
|
|
import { SVG } from '@wordpress/components';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
function Icon( { srcElement, size = 24, ...props } ) {
|
|
|
|
return (
|
|
|
|
isValidElement( srcElement ) &&
|
|
|
|
cloneElement( srcElement, {
|
|
|
|
width: size,
|
|
|
|
height: size,
|
|
|
|
...props,
|
|
|
|
} )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-02-10 13:24:02 +00:00
|
|
|
Icon.propTypes = {
|
2020-01-31 18:20:33 +00:00
|
|
|
srcElement: PropTypes.oneOfType( [
|
|
|
|
PropTypes.instanceOf( SVG ),
|
|
|
|
// HTMLImageElement is a global interface
|
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
PropTypes.instanceOf( HTMLImageElement ),
|
|
|
|
] ),
|
|
|
|
size: PropTypes.number,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Icon;
|