mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
Added typings for react-image-fallback package
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
// Type definitions for react-image-fallback 8.0
|
||||
// Project: https://github.com/socialtables/react-image-fallback
|
||||
// Definitions by: Ben Smith <https://github.com/8enSmith>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "react-image-fallback" {
|
||||
import * as React from "react"
|
||||
|
||||
class ReactImageFallback extends React.Component<
|
||||
ReactImageFallbackProps &
|
||||
React.DetailedHTMLProps<
|
||||
React.ImgHTMLAttributes<HTMLImageElement>,
|
||||
HTMLImageElement
|
||||
>,
|
||||
any
|
||||
> { }
|
||||
|
||||
export interface ReactImageFallbackProps {
|
||||
src: string
|
||||
fallbackImage: string | React.ReactElement<any> | any[]
|
||||
initialImage?: string | React.ReactElement<any>
|
||||
onLoad?: (event: React.SyntheticEvent<HTMLImageElement>) => void
|
||||
onError?: (event: React.SyntheticEvent<HTMLImageElement>) => void
|
||||
initialTimeout?: number
|
||||
}
|
||||
|
||||
export default ReactImageFallback
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import * as React from 'react';
|
||||
import ReactImageFallback, { ReactImageFallbackProps } from 'react-image-fallback';
|
||||
|
||||
class ReactImageFallbackSimple extends React.Component<ReactImageFallbackProps> {
|
||||
render() {
|
||||
return <ReactImageFallback
|
||||
src="my-image.png"
|
||||
fallbackImage="my-backup.png" />;
|
||||
}
|
||||
}
|
||||
|
||||
class ReactImageFallbackWithOptionals extends React.Component<ReactImageFallbackProps> {
|
||||
onLoad(event: React.SyntheticEvent<HTMLImageElement>) {
|
||||
}
|
||||
|
||||
onError(event: React.SyntheticEvent<HTMLImageElement>) {
|
||||
}
|
||||
|
||||
render() {
|
||||
return <ReactImageFallback
|
||||
src="my-image.png"
|
||||
fallbackImage="my-backup.png"
|
||||
initialImage="loader.gif"
|
||||
onLoad={this.onLoad}
|
||||
onError={this.onError}
|
||||
initialTimeout={1000} />;
|
||||
}
|
||||
}
|
||||
|
||||
class ReactImageFallbackWithImageTagProps extends React.Component<ReactImageFallbackProps> {
|
||||
render() {
|
||||
return <ReactImageFallback
|
||||
src="my-image.png"
|
||||
fallbackImage="my-backup.png"
|
||||
alt="alt text"
|
||||
width="123"
|
||||
className="customClass" />;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-image-fallback-tests.tsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user