@@ -4,13 +4,35 @@ import {
4
4
AspectRatioMode ,
5
5
NodeWidget ,
6
6
QSize ,
7
- TransformationMode
7
+ TransformationMode ,
8
8
} from "@nodegui/nodegui" ;
9
9
import { TextProps , setTextProps } from "../Text/RNText" ;
10
10
import { RNWidget } from "../config" ;
11
11
import { throwUnsupported , isValidUrl } from "../../utils/helpers" ;
12
12
import phin from "phin" ;
13
13
14
+ /**
15
+ * The Image component provides the ability to render images. It is based on
16
+ * [NodeGui's QPixmap](https://docs.nodegui.org/docs/api/generated/classes/qpixmap).
17
+ * ## Example
18
+ * ```javascript
19
+ * import React from "react";
20
+ * import { Renderer, Image, Window } from "@nodegui/react-nodegui";
21
+ * import { AspectRatioMode } from "@nodegui/nodegui";
22
+ * const App = () => {
23
+ * return (
24
+ * <Window>
25
+ * <Image
26
+ * aspectRatioMode={AspectRatioMode.KeepAspectRatio}
27
+ * size={{ height: 200, width: 150 }}
28
+ * src="https://place-hold.it/200x150"
29
+ * ></Image>
30
+ * </Window>
31
+ * );
32
+ * };
33
+ * Renderer.render(<App />);
34
+ * ```
35
+ */
14
36
export interface ImageProps extends TextProps {
15
37
src ?: string ;
16
38
aspectRatioMode ?: AspectRatioMode ;
@@ -29,7 +51,7 @@ const setImageProps = (
29
51
return ;
30
52
}
31
53
getLoadedPixmap ( imageUrlOrPath )
32
- . then ( pixmap => widget . setPixmap ( pixmap ) )
54
+ . then ( ( pixmap ) => widget . setPixmap ( pixmap ) )
33
55
. catch ( console . warn ) ;
34
56
} ,
35
57
set buffer ( imageBuffer : Buffer ) {
@@ -42,7 +64,7 @@ const setImageProps = (
42
64
} ,
43
65
set transformationMode ( mode : TransformationMode ) {
44
66
widget . setTransformationMode ( mode ) ;
45
- }
67
+ } ,
46
68
} ;
47
69
Object . assign ( setter , newProps ) ;
48
70
setTextProps ( widget , newProps , oldProps ) ;
0 commit comments