Skip to content

Commit a441935

Browse files
authored
Support imageId in Image, and fix props passing in Card.Image (#1852)
1 parent 61921b4 commit a441935

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

generatedTypes/src/components/image/index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export declare type ImageProps = RNImageProps & MarginModifiers & {
5252
* Default image source in case of an error
5353
*/
5454
errorSource?: ImageSourcePropType;
55+
/**
56+
* An imageId that can be used in sourceTransformer logic
57+
*/
58+
imageId?: string;
5559
};
5660
declare type Props = ImageProps & ForwardRefInjectedProps & BaseComponentInjectedProps;
5761
declare type State = {
@@ -146,6 +150,10 @@ declare const _default: React.ComponentClass<RNImageProps & Partial<Record<"marg
146150
* Default image source in case of an error
147151
*/
148152
errorSource?: ImageSourcePropType | undefined;
153+
/**
154+
* An imageId that can be used in sourceTransformer logic
155+
*/
156+
imageId?: string | undefined;
149157
} & {
150158
useCustomTheme?: boolean | undefined;
151159
}, any> & typeof Image;

src/components/card/CardImage.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,21 @@ class CardImage extends PureComponent<Props> {
4545
style,
4646
testID,
4747
overlayType,
48-
context: {borderStyle}
48+
context: {borderStyle},
49+
...others
4950
} = this.props;
5051

51-
if (source) {
52-
return (
53-
<View style={[this.styles.container, borderStyle, style]}>
54-
<Image
55-
testID={testID}
56-
source={source}
57-
style={[this.styles.image]}
58-
overlayType={overlayType}
59-
/>
60-
</View>
61-
);
62-
}
63-
return null;
52+
return (
53+
<View style={[this.styles.container, borderStyle, style]}>
54+
<Image
55+
testID={testID}
56+
source={source}
57+
style={[this.styles.image]}
58+
overlayType={overlayType}
59+
{...others}
60+
/>
61+
</View>
62+
);
6463
}
6564
}
6665

src/components/image/image.api.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
},
4242
{"name": "overlayColor", "type": "string", "description": "Pass a custom color for the overlay"},
4343
{"name": "customOverlayContent", "type": "JSX.Element", "description": "Render an overlay with custom content"},
44-
{"name": "errorSource", "type": "ImageSourcePropType", "description": "Default image source in case of an error"}
44+
{"name": "errorSource", "type": "ImageSourcePropType", "description": "Default image source in case of an error"},
45+
{"name": "imageId", "type": "string", "description": "An imageId that can be used in sourceTransformer logic"}
4546
],
4647
"snippet": [
4748
"<Image source={{uri: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/assets/images/card-example.jpg}}/>"

src/components/image/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ export type ImageProps = RNImageProps & MarginModifiers & {
6767
/**
6868
* Default image source in case of an error
6969
*/
70-
errorSource?: ImageSourcePropType
70+
errorSource?: ImageSourcePropType;
71+
/**
72+
* An imageId that can be used in sourceTransformer logic
73+
*/
74+
imageId?: string;
7175
};
7276

7377
type Props = ImageProps & ForwardRefInjectedProps & BaseComponentInjectedProps;

0 commit comments

Comments
 (0)