diff --git a/packages/lucide-vue-next/src/createLucideIcon.ts b/packages/lucide-vue-next/src/createLucideIcon.ts index 13bbf3e92..dd042f518 100644 --- a/packages/lucide-vue-next/src/createLucideIcon.ts +++ b/packages/lucide-vue-next/src/createLucideIcon.ts @@ -4,14 +4,13 @@ import defaultAttributes from './defaultAttributes'; // Create interface extending SVGAttributes export interface SVGProps extends Partial { - size?: 24 | number - strokeWidth?: number | string - absoluteStrokeWidth?: boolean + size?: 24 | number; + strokeWidth?: number | string; + absoluteStrokeWidth?: boolean; } - -export type IconNode = [elementName: string, attrs: Record][] -export type Icon = FunctionalComponent +export type IconNode = [elementName: string, attrs: Record][]; +export type Icon = FunctionalComponent; /** * Converts string to KebabCase * Copied from scripts/helper. If anyone knows how to properly import it here @@ -20,29 +19,31 @@ export type Icon = FunctionalComponent * @param {string} string * @returns {string} A kebabized string */ -export const toKebabCase = (string: string) => string.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase(); +export const toKebabCase = (string: string) => + string.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase(); -const createLucideIcon = (iconName: string, iconNode: IconNode): Icon => ( - { size, strokeWidth = 2, absoluteStrokeWidth, color, class: classes, ...props }, // props - { attrs, slots } // context +const createLucideIcon = + (iconName: string, iconNode: IconNode): Icon => + ( + { size, strokeWidth = 2, absoluteStrokeWidth, color, class: classes, ...props }, // props + { attrs, slots }, // context ) => { - return h( - 'svg', - { - ...defaultAttributes, - width: size || defaultAttributes.width, - height: size || defaultAttributes.height, - stroke: color || defaultAttributes.stroke, - 'stroke-width': absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth, - ...attrs, - class: ['lucide', `lucide-${toKebabCase(iconName)}`], - ...props, - }, - [ - ...iconNode.map(child => h(...child)), - ...(slots.default ? [slots.default()] : []) - ], - ); -}; + return h( + 'svg', + { + ...defaultAttributes, + width: size || defaultAttributes.width, + height: size || defaultAttributes.height, + stroke: color || defaultAttributes.stroke, + 'stroke-width': absoluteStrokeWidth + ? (Number(strokeWidth) * 24) / Number(size) + : strokeWidth, + ...attrs, + class: ['lucide', `lucide-${toKebabCase(iconName)}`], + ...props, + }, + [...iconNode.map((child) => h(...child)), ...(slots.default ? [slots.default()] : [])], + ); + }; export default createLucideIcon;