From 84b3c46b65d98336d48bb31975efe7e0040778ab Mon Sep 17 00:00:00 2001 From: Sukomal Dutta <100500478+Sukomal07@users.noreply.github.com> Date: Wed, 29 Nov 2023 01:29:37 +0530 Subject: [PATCH] remove extra space in svg class attribute (#1703) * remove extra space in svg class attribute * Update packages/lucide-react/src/createLucideIcon.ts Co-authored-by: Jakob Guddas --------- Co-authored-by: Jakob Guddas --- packages/lucide-react/src/createLucideIcon.ts | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/packages/lucide-react/src/createLucideIcon.ts b/packages/lucide-react/src/createLucideIcon.ts index 46622afee..daf73e7e3 100644 --- a/packages/lucide-react/src/createLucideIcon.ts +++ b/packages/lucide-react/src/createLucideIcon.ts @@ -1,14 +1,21 @@ -import { forwardRef, createElement, ReactSVG, SVGProps, ForwardRefExoticComponent, RefAttributes } from 'react'; +import { + forwardRef, + createElement, + ReactSVG, + SVGProps, + ForwardRefExoticComponent, + RefAttributes, +} from 'react'; import defaultAttributes from './defaultAttributes'; -export type IconNode = [elementName: keyof ReactSVG, attrs: Record][] +export type IconNode = [elementName: keyof ReactSVG, attrs: Record][]; -export type SVGAttributes = Partial> -type ComponentAttributes = RefAttributes & SVGAttributes +export type SVGAttributes = Partial>; +type ComponentAttributes = RefAttributes & SVGAttributes; export interface LucideProps extends ComponentAttributes { - size?: string | number - absoluteStrokeWidth?: boolean + size?: string | number; + absoluteStrokeWidth?: boolean; } export type LucideIcon = ForwardRefExoticComponent; @@ -20,7 +27,11 @@ export type LucideIcon = ForwardRefExoticComponent; * @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() + .trim(); const createLucideIcon = (iconName: string, iconNode: IconNode): LucideIcon => { const Component = forwardRef( @@ -39,11 +50,9 @@ const createLucideIcon = (iconName: string, iconNode: IconNode): LucideIcon => { }, [ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)), - ...( - (Array.isArray(children) ? children : [children]) || [] - ) - ], - ), + ...(Array.isArray(children) ? children : [children]), + ] + ) ); Component.displayName = `${iconName}`; @@ -51,4 +60,4 @@ const createLucideIcon = (iconName: string, iconNode: IconNode): LucideIcon => { return Component; }; -export default createLucideIcon +export default createLucideIcon;