Files
lucide/packages/featherity-react/getReactComponent.js
T
2020-08-14 23:20:19 +02:00

29 lines
765 B
JavaScript

import { forwardRef, createElement } from 'react';
import PropTypes from 'prop-types';
export default (iconName, [tag, attrs, children]) => {
const Component = forwardRef(({ color = 'currentColor', size = 24, width = 2, ...rest }, ref) =>
createElement(
tag,
{
ref,
...attrs,
width: size,
height: size,
color,
strokeWidth: width,
...rest,
},
children.map(([childTag, childAttrs]) => createElement(childTag, childAttrs)),
),
);
Component.propTypes = {
color: PropTypes.string,
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
};
Component.displayName = `${iconName}`;
};