Adding type definitions for react-medium-image-zoom (#33911)

* Added type definitions for react-medium-image-zoom

* fixes for react-medium-image-zoom

* fixes for react-medium-image-zoom
This commit is contained in:
James Bellamy 2019-03-15 17:57:58 +00:00 committed by Wesley Wigham
parent d6a5af9170
commit ea24e64a67
4 changed files with 92 additions and 0 deletions

View File

@ -0,0 +1,43 @@
// Type definitions for react-medium-image-zoom 3.0
// Project: https://github.com/rpearce/react-medium-image-zoom#readme
// Definitions by: James Bellamy <https://github.com/james-ff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.3
import * as React from "react";
export interface ImageZoom_Image {
src: string;
alt?: string;
className?: string;
style?: object;
}
export interface ImageZoom_ZoomImage {
src?: string;
alt?: string;
className?: string;
style?: object;
}
export interface ImageZoomDefaultStyles {
zoomContainer?: object;
overlay?: object;
image?: object;
zoomImage?: object;
}
export interface ImageZoomProps {
image: ImageZoom_Image;
zoomImage?: ImageZoom_ZoomImage;
zoomMargin?: number;
isZoomed?: boolean;
shouldHandleZoom?: () => boolean;
shouldReplaceImage?: boolean;
shouldRespectMaxDimension?: boolean;
defaultStyles?: ImageZoomDefaultStyles;
onZoom?: () => object;
onUnzoom?: () => object;
}
export default class ImageZoom extends React.Component<ImageZoomProps, any> {}

View File

@ -0,0 +1,23 @@
import * as React from "react";
import ImageZoom from "react-medium-image-zoom";
const component: React.FC = () => {
return (
<div>
<ImageZoom
image={{
src: "https://raw.githubusercontent.com/rpearce/react-medium-image-zoom/master/docs/bridge.jpg",
alt: "Golden Gate Bridge",
className: "img"
}}
zoomImage={{
src: "https://raw.githubusercontent.com/rpearce/react-medium-image-zoom/master/docs/bridge-big.jpg",
alt: "Golden Gate Bridge",
className: "img--zoomed"
}}
/>
</div>
);
};
export default component;

View File

@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-medium-image-zoom-tests.tsx"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }