Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lucide icon color issue in all the components #2440

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,28 @@ type IPrimitiveIcon = {
stroke?: string;
as?: React.ElementType;
className?: string;
classNameColor?: string;
};

const PrimitiveIcon = React.forwardRef<
React.ElementRef<typeof Svg>,
IPrimitiveIcon & React.ComponentPropsWithoutRef<typeof Svg>
IPrimitiveIcon
>(
(
{
height,
width,
fill,
color,
classNameColor,
size,
stroke = 'currentColor',
stroke,
as: AsComp,
...props
},
ref
) => {
color = color ?? classNameColor;
const sizeProps = useMemo(() => {
if (size) return { size };
if (height && width) return { height, width };
Expand All @@ -117,29 +120,21 @@ const PrimitiveIcon = React.forwardRef<
return {};
}, [size, height, width]);

const colorProps =
stroke === 'currentColor' && color !== undefined ? color : stroke;
let colorProps = {};
if (fill) {
colorProps = { ...colorProps, fill: fill };
}
if (stroke !== 'currentColor') {
colorProps = { ...colorProps, stroke: stroke };
} else if (stroke === 'currentColor' && color !== undefined) {
colorProps = { ...colorProps, stroke: color };
}

if (AsComp) {
return (
<AsComp
ref={ref}
fill={fill}
{...props}
{...sizeProps}
stroke={colorProps}
/>
);
return <AsComp ref={ref} {...props} {...sizeProps} {...colorProps} />;
}
return (
<Svg
ref={ref}
height={height}
width={width}
fill={fill}
stroke={colorProps}
{...props}
/>
<Svg ref={ref} height={height} width={width} {...colorProps} {...props} />
);
}
);
Expand Down Expand Up @@ -169,6 +164,7 @@ cssInterop(UIAccordion, { className: 'style' });
cssInterop(UIAccordion.Item, { className: 'style' });
cssInterop(UIAccordion.Header, { className: 'style' });
cssInterop(UIAccordion.Trigger, { className: 'style' });
//@ts-ignore
cssInterop(UIAccordion.Icon, { className: 'style' });
cssInterop(UIAccordion.TitleText, { className: 'style' });
cssInterop(UIAccordion.Content, { className: 'style' });
Expand All @@ -180,9 +176,8 @@ cssInterop(UIAccordion.Icon, {
nativeStyleToProp: {
height: true,
width: true,
// @ts-ignore
fill: true,
color: true,
color: 'classNameColor',
stroke: true,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,27 @@ type IPrimitiveIcon = {
stroke?: string;
as?: React.ElementType;
className?: string;
classNameColor?: string;
};
const PrimitiveIcon = React.forwardRef<
React.ElementRef<typeof Svg>,
IPrimitiveIcon & React.ComponentPropsWithoutRef<typeof Svg>
IPrimitiveIcon
>(
(
{
height,
width,
fill,
color,
classNameColor,
size,
stroke = 'currentColor',
stroke,
as: AsComp,
...props
},
ref
) => {
color = color ?? classNameColor;
const sizeProps = useMemo(() => {
if (size) return { size };
if (height && width) return { height, width };
Expand All @@ -60,29 +63,21 @@ const PrimitiveIcon = React.forwardRef<
return {};
}, [size, height, width]);

const colorProps =
stroke === 'currentColor' && color !== undefined ? color : stroke;
let colorProps = {};
if (fill) {
colorProps = { ...colorProps, fill: fill };
}
if (stroke !== 'currentColor') {
colorProps = { ...colorProps, stroke: stroke };
} else if (stroke === 'currentColor' && color !== undefined) {
colorProps = { ...colorProps, stroke: color };
}

if (AsComp) {
return (
<AsComp
ref={ref}
fill={fill}
{...props}
{...sizeProps}
stroke={colorProps}
/>
);
return <AsComp ref={ref} {...props} {...sizeProps} {...colorProps} />;
}
return (
<Svg
ref={ref}
height={height}
width={width}
fill={fill}
stroke={colorProps}
{...props}
/>
<Svg ref={ref} height={height} width={width} {...colorProps} {...props} />
);
}
);
Expand Down Expand Up @@ -142,15 +137,15 @@ cssInterop(UIActionsheet.FlatList, {
});
cssInterop(UIActionsheet.SectionList, { className: 'style' });
cssInterop(UIActionsheet.SectionHeaderText, { className: 'style' });
// @ts-ignore
cssInterop(UIActionsheet.Icon, {
className: {
target: 'style',
nativeStyleToProp: {
height: true,
width: true,
// @ts-ignore
fill: true,
color: true,
color: 'classNameColor',
stroke: true,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,37 +114,53 @@ type IPrimitiveIcon = React.ComponentPropsWithoutRef<typeof Svg> & {
stroke?: string;
as?: React.ElementType;
className?: string;
classNameColor?: string;
};

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]);
>(
(
{
height,
width,
fill,
color,
classNameColor,
size,
stroke,
as: AsComp,
...props
},
ref
) => {
color = color ?? classNameColor;
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} />;
let colorProps = {};
if (fill) {
colorProps = { ...colorProps, fill: fill };
}
if (stroke !== 'currentColor') {
colorProps = { ...colorProps, stroke: stroke };
} else if (stroke === 'currentColor' && color !== undefined) {
colorProps = { ...colorProps, stroke: color };
}

if (AsComp) {
return <AsComp ref={ref} {...props} {...sizeProps} {...colorProps} />;
}
return (
<Svg ref={ref} height={height} width={width} {...colorProps} {...props} />
);
}
return (
<Svg ref={ref} height={height} width={width} {...colorProps} {...props} />
);
});
);

const IconWrapper = React.forwardRef<
React.ElementRef<typeof PrimitiveIcon>,
Expand All @@ -162,15 +178,16 @@ export const UIAlert = createAlert({
cssInterop(UIAlert, { className: 'style' });
//@ts-ignore
cssInterop(UIAlert.Text, { className: 'style' });
//@ts-ignore
cssInterop(IconWrapper, {
className: {
target: 'style',
nativeStyleToProp: {
height: true,
width: true,
// @ts-ignore
//@ts-ignore
fill: true,
color: true,
color: 'classNameColor',
stroke: true,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,49 +102,67 @@ type IPrimitiveIcon = React.ComponentPropsWithoutRef<typeof Svg> & {
stroke?: string;
as?: React.ElementType;
className?: string;
classNameColor?: string;
};

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,
classNameColor,
size,
stroke,
as: AsComp,
...props
},
ref
) => {
color = color ?? classNameColor;
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 (fill) {
colorProps = { ...colorProps, fill: fill };
}
if (stroke !== 'currentColor') {
colorProps = { ...colorProps, stroke: stroke };
} else if (stroke === 'currentColor' && color !== undefined) {
colorProps = { ...colorProps, stroke: color };
}

if (AsComp) {
return <AsComp ref={ref} {...props} {...sizeProps} {...colorProps} />;
}
return (
<Svg ref={ref} height={height} width={width} {...colorProps} {...props} />
);
}
return (
<Svg ref={ref} height={height} width={width} {...colorProps} {...props} />
);
});
);

const ContextView = withStyleContext(View, SCOPE);
cssInterop(ContextView, { className: 'style' });
//@ts-ignore
cssInterop(PrimitiveIcon, {
className: {
target: 'style',
nativeStyleToProp: {
height: true,
width: true,
// @ts-ignore
//@ts-ignore
fill: true,
color: true,
color: 'classNameColor',
stroke: true,
},
},
Expand Down
Loading
Loading