initial commit
This commit is contained in:
29
packages/woocommerce-blocks/assets/js/icons/icon/index.tsx
Normal file
29
packages/woocommerce-blocks/assets/js/icons/icon/index.tsx
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { cloneElement, isValidElement } from '@wordpress/element';
|
||||
import type { HTMLProps, ReactElement } from 'react';
|
||||
|
||||
interface IconProps {
|
||||
srcElement?: ReactElement;
|
||||
size?: number;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
function Icon( {
|
||||
srcElement,
|
||||
size = 24,
|
||||
...props
|
||||
}: IconProps &
|
||||
HTMLProps< HTMLImageElement | SVGElement > ): ReactElement | null {
|
||||
if ( ! isValidElement( srcElement ) ) {
|
||||
return null;
|
||||
}
|
||||
return cloneElement( srcElement, {
|
||||
width: size,
|
||||
height: size,
|
||||
...props,
|
||||
} );
|
||||
}
|
||||
|
||||
export default Icon;
|
Reference in New Issue
Block a user