mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-17 14:28:25 +00:00
* extract workflow * Add aliases build * Setup types building for aliases * Add types generation for aliases * Finish React Aliases * Finish aliases for lucide-react * setup aliases preact * Fix aliases in preact * Add aliases preact * Add aliases lucide-react-native * Fix solid js build * update lock file * Improve solid for solid start * update import * update import * lucide solid fix types generation * Fix lucide sold * Fix svelte aliases * update lockfile * Fix imports * Fix solid js issues * Add aliases to the vue packages * Fix lucide react native * Test alpha versions lucide-vue, lucide-vue-next, lucide-svelte
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { forwardRef, createElement, ReactSVG, ReactNode, FunctionComponent } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import * as NativeSvg from 'react-native-svg';
|
|
import defaultAttributes from './defaultAttributes';
|
|
import type { SvgProps } from 'react-native-svg';
|
|
type IconNode = [elementName: keyof ReactSVG, attrs: Record<string, string>][]
|
|
|
|
|
|
export interface LucideProps extends SvgProps {
|
|
size?: string | number
|
|
}
|
|
|
|
const createLucideIcon = (iconName: string, iconNode: IconNode) => {
|
|
const Component = forwardRef(
|
|
({ color = 'currentColor', size = 24, strokeWidth = 2, children, ...rest }: LucideProps, ref) =>
|
|
createElement(
|
|
NativeSvg.Svg,
|
|
{
|
|
ref,
|
|
...defaultAttributes,
|
|
width: size,
|
|
height: size,
|
|
stroke: color,
|
|
strokeWidth,
|
|
...rest,
|
|
},
|
|
[
|
|
...iconNode.map(([tag, attrs]) => {
|
|
const upperCasedTag = (tag.charAt(0).toUpperCase() + tag.slice(1)) as keyof (typeof NativeSvg);
|
|
return createElement(NativeSvg[upperCasedTag] as FunctionComponent<Record<string, string>>, attrs);
|
|
}),
|
|
...(children as ReactNode[] || []),
|
|
],
|
|
),
|
|
);
|
|
|
|
Component.propTypes = {
|
|
color: PropTypes.string,
|
|
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
strokeWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
};
|
|
|
|
Component.displayName = `${iconName}`;
|
|
|
|
return Component;
|
|
};
|
|
|
|
export default createLucideIcon;
|