Create conductor-animate types (#37431)

Cleanup

Add TS version

Use interface over type

Remove unnecessary semicolons

Use TS version 2.8
This commit is contained in:
Tae Kim 2019-08-07 16:15:08 -07:00 committed by Nathan Shively-Sanders
parent 9fa6c4b9cd
commit 217f9fc253
4 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,29 @@
import * as React from 'react';
import { Conductor, Animated } from 'conductor-animate';
// Define the Animation mapping
const animations = {
Fade: () => <div>Fake Animation</div>,
};
// Define the configuration
const config = {
HeaderSection: {
animation: 'Fade',
duration: 500,
delay: 200,
},
};
const App = () => {
// Render the Page w/ the Conductor and Animated
return (
<Conductor animations={animations} config={config}>
<Animated id="HeaderSection">
<h1>This Header will fade in </h1>
</Animated>
</Conductor>
);
};
export default App;

32
types/conductor-animate/index.d.ts vendored Normal file
View File

@ -0,0 +1,32 @@
// Type definitions for conductor-animate 1.0
// Project: https://github.com/TaeKimJR/conductor-animate#readme
// Definitions by: Tae Kim <https://github.com/DefinitelyTyped>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from 'react';
interface Animations {
[K: string]: React.ComponentClass<any> | React.FunctionComponent<any>;
}
interface Config {
animation: string;
}
interface AnimatedProps {
additional?: object;
children?: React.ReactNode | React.ReactNodeArray | null;
id: string;
}
declare class Animated extends React.PureComponent<AnimatedProps> { }
interface ConductorProps {
animations: Animations;
children: React.ReactNode | React.ReactNodeArray;
config: { [K: string]: Config } | ((id: string, additional: object) => Config);
}
declare class Conductor extends React.PureComponent<ConductorProps> { }
export { Animated, Conductor };

View File

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

View File

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