diff --git a/example/storybook-nativewind/src/core-components/nativewind/accordion/index.tsx b/example/storybook-nativewind/src/core-components/nativewind/accordion/index.tsx index ca4711a77..ca8d35fbf 100644 --- a/example/storybook-nativewind/src/core-components/nativewind/accordion/index.tsx +++ b/example/storybook-nativewind/src/core-components/nativewind/accordion/index.tsx @@ -90,11 +90,12 @@ type IPrimitiveIcon = { stroke?: string; as?: React.ElementType; className?: string; + classNameColor?: string; }; const PrimitiveIcon = React.forwardRef< React.ElementRef, - IPrimitiveIcon & React.ComponentPropsWithoutRef + IPrimitiveIcon >( ( { @@ -102,13 +103,15 @@ const PrimitiveIcon = React.forwardRef< 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 }; @@ -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 ( - - ); + return ; } return ( - + ); } ); @@ -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' }); @@ -180,9 +176,8 @@ cssInterop(UIAccordion.Icon, { nativeStyleToProp: { height: true, width: true, - // @ts-ignore fill: true, - color: true, + color: 'classNameColor', stroke: true, }, }, diff --git a/example/storybook-nativewind/src/core-components/nativewind/actionsheet/index.tsx b/example/storybook-nativewind/src/core-components/nativewind/actionsheet/index.tsx index e80735b9d..ad40846e0 100644 --- a/example/storybook-nativewind/src/core-components/nativewind/actionsheet/index.tsx +++ b/example/storybook-nativewind/src/core-components/nativewind/actionsheet/index.tsx @@ -34,10 +34,11 @@ type IPrimitiveIcon = { stroke?: string; as?: React.ElementType; className?: string; + classNameColor?: string; }; const PrimitiveIcon = React.forwardRef< React.ElementRef, - IPrimitiveIcon & React.ComponentPropsWithoutRef + IPrimitiveIcon >( ( { @@ -45,13 +46,15 @@ const PrimitiveIcon = React.forwardRef< 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 }; @@ -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 ( - - ); + return ; } return ( - + ); } ); @@ -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, }, }, diff --git a/example/storybook-nativewind/src/core-components/nativewind/alert/index.tsx b/example/storybook-nativewind/src/core-components/nativewind/alert/index.tsx index f98aceb91..cd1d60416 100644 --- a/example/storybook-nativewind/src/core-components/nativewind/alert/index.tsx +++ b/example/storybook-nativewind/src/core-components/nativewind/alert/index.tsx @@ -114,37 +114,53 @@ type IPrimitiveIcon = React.ComponentPropsWithoutRef & { stroke?: string; as?: React.ElementType; className?: string; + classNameColor?: string; }; - const PrimitiveIcon = React.forwardRef< React.ElementRef, 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 ; + 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 ; + } + return ( + + ); } - return ( - - ); -}); +); const IconWrapper = React.forwardRef< React.ElementRef, @@ -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, }, }, diff --git a/example/storybook-nativewind/src/core-components/nativewind/badge/index.tsx b/example/storybook-nativewind/src/core-components/nativewind/badge/index.tsx index 42bf60164..0130802f4 100644 --- a/example/storybook-nativewind/src/core-components/nativewind/badge/index.tsx +++ b/example/storybook-nativewind/src/core-components/nativewind/badge/index.tsx @@ -102,49 +102,67 @@ type IPrimitiveIcon = React.ComponentPropsWithoutRef & { stroke?: string; as?: React.ElementType; className?: string; + classNameColor?: string; }; const PrimitiveIcon = React.forwardRef< React.ElementRef, 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 ; +>( + ( + { + 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 ; + } + return ( + + ); } - return ( - - ); -}); +); 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, }, }, diff --git a/example/storybook-nativewind/src/core-components/nativewind/button/index.tsx b/example/storybook-nativewind/src/core-components/nativewind/button/index.tsx index 1cb78b368..b0b9b10c7 100644 --- a/example/storybook-nativewind/src/core-components/nativewind/button/index.tsx +++ b/example/storybook-nativewind/src/core-components/nativewind/button/index.tsx @@ -36,21 +36,29 @@ type IPrimitiveIcon = React.ComponentPropsWithoutRef & { size?: number | string; stroke?: string; as?: React.ElementType; + className?: string; + classNameColor?: string; }; -const PrimitiveIcon = React.forwardRef( + +const PrimitiveIcon = React.forwardRef< + React.ElementRef, + IPrimitiveIcon +>( ( { height, width, fill, color, + classNameColor, size, - stroke = 'currentColor', + stroke, as: AsComp, ...props - }: IPrimitiveIcon, - ref: React.Ref + }, + ref ) => { + color = color ?? classNameColor; const sizeProps = useMemo(() => { if (size) return { size }; if (height && width) return { height, width }; @@ -59,29 +67,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 ( - - ); + return ; } return ( - + ); } ); @@ -105,16 +105,16 @@ cssInterop(UIButton.Group, { className: 'style' }); cssInterop(UIButton.Spinner, { className: { target: 'style', nativeStyleToProp: { color: true } }, }); - +//@ts-ignore cssInterop(PrimitiveIcon, { className: { target: 'style', nativeStyleToProp: { height: true, width: true, - // @ts-ignore + //@ts-ignore fill: true, - color: true, + color: 'classNameColor', stroke: true, }, }, diff --git a/example/storybook-nativewind/src/core-components/nativewind/checkbox/index.tsx b/example/storybook-nativewind/src/core-components/nativewind/checkbox/index.tsx index aaaa8f018..93300d5bf 100644 --- a/example/storybook-nativewind/src/core-components/nativewind/checkbox/index.tsx +++ b/example/storybook-nativewind/src/core-components/nativewind/checkbox/index.tsx @@ -37,6 +37,7 @@ type IPrimitiveIcon = React.ComponentPropsWithoutRef & { stroke?: string; as?: React.ElementType; className?: string; + classNameColor?: string; }; const IconWrapper = React.forwardRef< @@ -49,32 +50,48 @@ const IconWrapper = React.forwardRef< const PrimitiveIcon = React.forwardRef< React.ElementRef, 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 ; + 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 ; + } + return ( + + ); } - return ( - - ); -}); +); const SCOPE = 'CHECKBOX'; const UICheckbox = createCheckbox({ @@ -94,15 +111,16 @@ cssInterop(UICheckbox, { className: 'style' }); cssInterop(UICheckbox.Group, { className: 'style' }); cssInterop(LabelWrapper, { className: 'style' }); cssInterop(IndicatorWrapper, { 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, }, }, diff --git a/example/storybook-nativewind/src/core-components/nativewind/fab/index.tsx b/example/storybook-nativewind/src/core-components/nativewind/fab/index.tsx index f15448243..a33387755 100644 --- a/example/storybook-nativewind/src/core-components/nativewind/fab/index.tsx +++ b/example/storybook-nativewind/src/core-components/nativewind/fab/index.tsx @@ -22,37 +22,54 @@ type IPrimitiveIcon = React.ComponentPropsWithoutRef & { stroke?: string; as?: React.ElementType; className?: string; + classNameColor?: string; }; const PrimitiveIcon = React.forwardRef< React.ElementRef, 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 ; + 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 ; + } + return ( + + ); } - return ( - - ); -}); +); const SCOPE = 'FAB'; const UIFab = createFab({ @@ -66,15 +83,16 @@ const UIFab = createFab({ cssInterop(UIFab, { className: 'style' }); cssInterop(UIFab.Label, { className: 'style' }); +//@ts-ignore cssInterop(UIFab.Icon, { className: { target: 'style', nativeStyleToProp: { height: true, width: true, - // @ts-ignore + //@ts-ignore fill: true, - color: true, + color: 'classNameColor', stroke: true, }, }, diff --git a/example/storybook-nativewind/src/core-components/nativewind/icon/index.tsx b/example/storybook-nativewind/src/core-components/nativewind/icon/index.tsx index 662a00556..a63928399 100644 --- a/example/storybook-nativewind/src/core-components/nativewind/icon/index.tsx +++ b/example/storybook-nativewind/src/core-components/nativewind/icon/index.tsx @@ -90,7 +90,7 @@ cssInterop(UIIcon, { height: true, width: true, fill: true, - color: true, + color: 'classNameColor', stroke: true, }, }, diff --git a/example/storybook-nativewind/src/core-components/nativewind/input/index.tsx b/example/storybook-nativewind/src/core-components/nativewind/input/index.tsx index 3f2658ea4..3f5013b5d 100644 --- a/example/storybook-nativewind/src/core-components/nativewind/input/index.tsx +++ b/example/storybook-nativewind/src/core-components/nativewind/input/index.tsx @@ -23,37 +23,54 @@ type IPrimitiveIcon = { stroke?: string; as?: React.ElementType; className?: string; + classNameColor?: string; }; const PrimitiveIcon = React.forwardRef< React.ElementRef, 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 ; + 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 ; + } + return ( + + ); } - return ( - - ); -}); +); const InputWrapper = React.forwardRef< React.ElementRef, @@ -146,15 +163,15 @@ cssInterop(UIInput.Slot, { className: 'style' }); cssInterop(UIInput.Input, { className: { target: 'style', nativeStyleToProp: { textAlign: true } }, }); +//@ts-ignore cssInterop(UIInput.Icon, { className: { target: 'style', nativeStyleToProp: { height: true, width: true, - // @ts-ignore fill: true, - color: true, + color: 'classNameColor', stroke: true, }, }, diff --git a/example/storybook-nativewind/src/core-components/nativewind/radio/index.tsx b/example/storybook-nativewind/src/core-components/nativewind/radio/index.tsx index 837b02009..78733932c 100644 --- a/example/storybook-nativewind/src/core-components/nativewind/radio/index.tsx +++ b/example/storybook-nativewind/src/core-components/nativewind/radio/index.tsx @@ -43,37 +43,54 @@ type IPrimitiveIcon = { stroke?: string; as?: React.ElementType; className?: string; + classNameColor?: string; }; const PrimitiveIcon = React.forwardRef< React.ElementRef, 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 ; + 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 ; + } + return ( + + ); } - return ( - - ); -}); +); const radioStyle = tva({ base: 'group/radio flex-row justify-start items-center web:cursor-pointer data-[disabled=true]:web:cursor-not-allowed', @@ -151,15 +168,15 @@ cssInterop(UIRadio, { className: 'style' }); cssInterop(UIRadio.Group, { className: 'style' }); cssInterop(IndicatorWrapper, { className: 'style' }); cssInterop(LabelWrapper, { className: 'style' }); +//@ts-ignore cssInterop(IconWrapper, { className: { target: 'style', nativeStyleToProp: { height: true, width: true, - // @ts-ignore fill: true, - color: true, + color: 'classNameColor', stroke: true, }, }, diff --git a/example/storybook-nativewind/src/core-components/nativewind/select/index.tsx b/example/storybook-nativewind/src/core-components/nativewind/select/index.tsx index 4e7288b55..2c6ec85f3 100644 --- a/example/storybook-nativewind/src/core-components/nativewind/select/index.tsx +++ b/example/storybook-nativewind/src/core-components/nativewind/select/index.tsx @@ -96,37 +96,54 @@ type IPrimitiveIcon = { stroke?: string; as?: React.ElementType; className?: string; + classNameColor?: string; }; const PrimitiveIcon = React.forwardRef< React.ElementRef, 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 ; + 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 ; + } + return ( + + ); } - return ( - - ); -}); +); const UISelect = createSelect( { @@ -159,7 +176,7 @@ cssInterop(UISelect.Input, { className: { target: 'style', nativeStyleToProp: { textAlign: true } }, }); cssInterop(SelectTriggerWrapper, { className: 'style' }); - +//@ts-ignore cssInterop(UISelect.Icon, { className: { target: 'style', @@ -167,7 +184,7 @@ cssInterop(UISelect.Icon, { height: true, width: true, fill: true, - color: true, + color: 'classNameColor', stroke: true, }, },