mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-18 14:38:24 +00:00
* fix: consistent icon name class * merge classes * fix vue-next * update test snapshots * fix vue-next * fix test * fix solid * proper deduplication * update snapshots * preact * refactor * deprecated * refactor tests --------- Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
32 lines
849 B
TypeScript
32 lines
849 B
TypeScript
import { createElement, forwardRef } from 'react';
|
|
import { mergeClasses, toKebabCase, toPascalCase } from '@lucide/shared';
|
|
import { IconNode, LucideProps } from './types';
|
|
import Icon from './Icon';
|
|
|
|
/**
|
|
* Create a Lucide icon component
|
|
* @param {string} iconName
|
|
* @param {array} iconNode
|
|
* @returns {ForwardRefExoticComponent} LucideIcon
|
|
*/
|
|
const createLucideIcon = (iconName: string, iconNode: IconNode) => {
|
|
const Component = forwardRef<SVGSVGElement, LucideProps>(({ className, ...props }, ref) =>
|
|
createElement(Icon, {
|
|
ref,
|
|
iconNode,
|
|
className: mergeClasses(
|
|
`lucide-${toKebabCase(toPascalCase(iconName))}`,
|
|
`lucide-${iconName}`,
|
|
className,
|
|
),
|
|
...props,
|
|
}),
|
|
);
|
|
|
|
Component.displayName = toPascalCase(iconName);
|
|
|
|
return Component;
|
|
};
|
|
|
|
export default createLucideIcon;
|