mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-13 13:48:26 +00:00
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 <github@jguddas.de> --------- Co-authored-by: Jakob Guddas <github@jguddas.de>
This commit is contained in:
co-authored by
Jakob Guddas
parent
1a09e7fb39
commit
84b3c46b65
@@ -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<string, string>][]
|
||||
export type IconNode = [elementName: keyof ReactSVG, attrs: Record<string, string>][];
|
||||
|
||||
export type SVGAttributes = Partial<SVGProps<SVGSVGElement>>
|
||||
type ComponentAttributes = RefAttributes<SVGSVGElement> & SVGAttributes
|
||||
export type SVGAttributes = Partial<SVGProps<SVGSVGElement>>;
|
||||
type ComponentAttributes = RefAttributes<SVGSVGElement> & SVGAttributes;
|
||||
|
||||
export interface LucideProps extends ComponentAttributes {
|
||||
size?: string | number
|
||||
absoluteStrokeWidth?: boolean
|
||||
size?: string | number;
|
||||
absoluteStrokeWidth?: boolean;
|
||||
}
|
||||
|
||||
export type LucideIcon = ForwardRefExoticComponent<LucideProps>;
|
||||
@@ -20,7 +27,11 @@ export type LucideIcon = ForwardRefExoticComponent<LucideProps>;
|
||||
* @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<SVGSVGElement, LucideProps>(
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user