2021-03-05 14:03:48 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2021-04-08 12:31:12 +00:00
|
|
|
import { cloneElement, isValidElement } from '@wordpress/element';
|
2021-08-20 11:55:30 +00:00
|
|
|
import type { HTMLProps, ReactElement } from 'react';
|
2021-03-05 14:03:48 +00:00
|
|
|
|
2021-12-02 16:56:53 +00:00
|
|
|
export interface IconProps {
|
2021-03-05 14:03:48 +00:00
|
|
|
srcElement?: ReactElement;
|
|
|
|
size?: number;
|
|
|
|
className?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
function Icon( {
|
|
|
|
srcElement,
|
|
|
|
size = 24,
|
|
|
|
...props
|
2021-08-20 11:55:30 +00:00
|
|
|
}: IconProps &
|
|
|
|
HTMLProps< HTMLImageElement | SVGElement > ): ReactElement | null {
|
2021-03-05 14:03:48 +00:00
|
|
|
if ( ! isValidElement( srcElement ) ) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return cloneElement( srcElement, {
|
|
|
|
width: size,
|
|
|
|
height: size,
|
|
|
|
...props,
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Icon;
|