@hugeicons/react
Version:
HugeIcons Pro React Component Library https://hugeicons.com
43 lines (40 loc) • 1.42 kB
JavaScript
import { forwardRef, createElement } from 'react';
const defaultAttributes = {
xmlns: 'http://www.w3.org/2000/svg',
width: 24,
height: 24,
viewBox: '0 0 24 24',
fill: 'none',
};
const HugeiconsIcon = forwardRef(({ color = 'currentColor', size = 24, strokeWidth, absoluteStrokeWidth = false, className = '', altIcon, showAlt = false, icon, ...rest }, ref) => {
const calculatedStrokeWidth = strokeWidth !== undefined
? (absoluteStrokeWidth ? (Number(strokeWidth) * 24) / Number(size) : strokeWidth)
: undefined;
const strokeProps = calculatedStrokeWidth !== undefined ? {
strokeWidth: calculatedStrokeWidth,
stroke: 'currentColor'
} : {};
const elementProps = {
ref,
...defaultAttributes,
width: size,
height: size,
color,
className,
...strokeProps,
...rest,
};
const currentIcon = (showAlt && altIcon) ? altIcon : icon;
// Create SVG children without adding them as an icon prop
const svgChildren = currentIcon.map(([tag, attrs]) => {
return createElement(tag, {
...attrs,
...strokeProps,
key: attrs.key
});
});
return createElement('svg', elementProps, svgChildren);
});
HugeiconsIcon.displayName = 'HugeiconsIcon';
export { HugeiconsIcon, HugeiconsIcon as default };
//# sourceMappingURL=HugeiconsIcon.js.map