@@ -4,13 +4,35 @@ import {
44 AspectRatioMode ,
55 NodeWidget ,
66 QSize ,
7- TransformationMode
7+ TransformationMode ,
88} from "@nodegui/nodegui" ;
99import { TextProps , setTextProps } from "../Text/RNText" ;
1010import { RNWidget } from "../config" ;
1111import { throwUnsupported , isValidUrl } from "../../utils/helpers" ;
1212import phin from "phin" ;
1313
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+ */
1436export interface ImageProps extends TextProps {
1537 src ?: string ;
1638 aspectRatioMode ?: AspectRatioMode ;
@@ -29,7 +51,7 @@ const setImageProps = (
2951 return ;
3052 }
3153 getLoadedPixmap ( imageUrlOrPath )
32- . then ( pixmap => widget . setPixmap ( pixmap ) )
54+ . then ( ( pixmap ) => widget . setPixmap ( pixmap ) )
3355 . catch ( console . warn ) ;
3456 } ,
3557 set buffer ( imageBuffer : Buffer ) {
@@ -42,7 +64,7 @@ const setImageProps = (
4264 } ,
4365 set transformationMode ( mode : TransformationMode ) {
4466 widget . setTransformationMode ( mode ) ;
45- }
67+ } ,
4668 } ;
4769 Object . assign ( setter , newProps ) ;
4870 setTextProps ( widget , newProps , oldProps ) ;
0 commit comments