-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
index.js
27 lines (24 loc) · 880 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* WordPress dependencies
*/
import { cloneElement, forwardRef } from '@wordpress/element';
/** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
/**
* Return an SVG icon.
*
* @param {IconProps} props icon is the SVG component to render
* size is a number specifiying the icon size in pixels
* Other props will be passed to wrapped SVG component
* @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element.
*
* @return {JSX.Element} Icon component
*/
function Icon( { icon, size = 24, ...props }, ref ) {
return cloneElement( icon, {
width: size,
height: size,
...props,
ref,
} );
}
export default forwardRef( Icon );