Skip to content

Commit

Permalink
Merge pull request #2473 from gluestack/fix/v2-icons
Browse files Browse the repository at this point in the history
fix: lucide icon issue
  • Loading branch information
Viraj-10 authored Sep 18, 2024
2 parents 7ad0ea9 + 0ea5cbf commit a44b27b
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const PrimitiveIcon = React.forwardRef<
color,
classNameColor,
size,
stroke,
stroke = 'currentColor',
as: AsComp,
...props
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const PrimitiveIcon = React.forwardRef<
color,
classNameColor,
size,
stroke,
stroke = 'currentColor',
as: AsComp,
...props
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const PrimitiveIcon = React.forwardRef<
color,
classNameColor,
size,
stroke,
stroke = 'currentColor',
as: AsComp,
...props
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const PrimitiveIcon = React.forwardRef<
color,
classNameColor,
size,
stroke,
stroke = 'currentColor',
as: AsComp,
...props
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const PrimitiveIcon = React.forwardRef<
color,
classNameColor,
size,
stroke,
stroke = 'currentColor',
as: AsComp,
...props
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const PrimitiveIcon = React.forwardRef<
color,
classNameColor,
size,
stroke,
stroke = 'currentColor',
as: AsComp,
...props
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const PrimitiveIcon = React.forwardRef<
color,
classNameColor,
size,
stroke,
stroke = 'currentColor',
as: AsComp,
...props
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,46 @@ type IPrimitiveIcon = React.ComponentPropsWithoutRef<typeof Svg> & {
const PrimitiveIcon = React.forwardRef<
React.ElementRef<typeof Svg>,
IPrimitiveIcon
>(({ height, width, fill, color, size, stroke, as: AsComp, ...props }, ref) => {
const sizeProps = useMemo(() => {
if (size) return { size };
if (height && width) return { height, width };
if (height) return { height };
if (width) return { width };
return {};
}, [size, height, width]);

let colorProps = {};
if (color) {
colorProps = { ...colorProps, color: color };
}
if (stroke) {
colorProps = { ...colorProps, stroke: stroke };
}
if (fill) {
colorProps = { ...colorProps, fill: fill };
}
if (AsComp) {
return <AsComp ref={ref} {...sizeProps} {...colorProps} {...props} />;
>(
(
{
height,
width,
fill,
color,
size,
stroke = 'currentColor',
as: AsComp,
...props
},
ref
) => {
const sizeProps = useMemo(() => {
if (size) return { size };
if (height && width) return { height, width };
if (height) return { height };
if (width) return { width };
return {};
}, [size, height, width]);

let colorProps = {};
if (color) {
colorProps = { ...colorProps, color: color };
}
if (stroke) {
colorProps = { ...colorProps, stroke: stroke };
}
if (fill) {
colorProps = { ...colorProps, fill: fill };
}
if (AsComp) {
return <AsComp ref={ref} {...sizeProps} {...colorProps} {...props} />;
}
return (
<Svg ref={ref} height={height} width={width} {...colorProps} {...props} />
);
}
return (
<Svg ref={ref} height={height} width={width} {...colorProps} {...props} />
);
});
);

const formControlStyle = tva({
base: 'flex flex-col',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const PrimitiveIcon = React.forwardRef<
color,
classNameColor,
size,
stroke,
stroke = 'currentColor',
as: AsComp,
...props
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const PrimitiveIcon = React.forwardRef<
color,
classNameColor,
size,
stroke,
stroke = 'currentColor',
as: AsComp,
...props
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const PrimitiveIcon = React.forwardRef<
color,
classNameColor,
size,
stroke,
stroke = 'currentColor',
as: AsComp,
...props
},
Expand Down

0 comments on commit a44b27b

Please sign in to comment.