Merge pull request #34718 from shawnkoon/feature/add-react-typist

Add react-typist type definition
This commit is contained in:
Armando Aguirre
2019-04-16 17:00:45 -07:00
committed by GitHub
4 changed files with 143 additions and 0 deletions

59
types/react-typist/index.d.ts vendored Normal file
View File

@@ -0,0 +1,59 @@
// Type definitions for react-typist 2.0
// Project: https://github.com/jstejada/react-typist#readme
// Definitions by: Shawn Choi <https://github.com/shawnkoon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.1
import * as React from "react";
export namespace TreeView {
interface CursorProps {
show?: boolean;
blink?: boolean;
element?: string;
hideWhenDone?: boolean;
hideWhenDoneDelay?: number;
}
interface CurrentTextProps {
line: string;
lineIdx: number;
character: string;
charIdx: number;
defDelayGenerator: (
mn: number,
st: number
) => (...params: any) => number;
}
interface DelayProps {
ms: number;
}
class Delay extends React.Component<DelayProps> {}
interface BackSpaceProps {
count?: number;
delay?: number;
}
class Backspace extends React.Component<BackSpaceProps> {}
}
export interface TreeViewProps {
className?: string;
avgTypingDelay?: number;
stdTypingDelay?: number;
startDelay?: number;
cursor?: TreeView.CursorProps;
onCharacterTyped?: (char: string, charIndex: number) => void;
onLineTyped?: (line: string, lineIndex: number) => void;
onTypingDone?: () => void;
delayGenerator?: (
mean: number,
std: number,
current: TreeView.CurrentTextProps
) => number;
}
export class TreeView extends React.Component<TreeViewProps> {}
export default TreeView;

View File

@@ -0,0 +1,59 @@
import * as React from "react";
import Typist from "react-typist";
class ReactTypist extends React.Component {
state = {
renderMsg: false
};
onHeaderTyped = () => {
this.setState({ renderMsg: true });
}
render() {
const docs = "//github.com/jstejada/react-typist";
return (
<div className="TypistExample">
<Typist
className="TypistExample-header"
avgTypingDelay={40}
startDelay={2000}
onTypingDone={this.onHeaderTyped}
>
<a href={docs}>React Typist</a>
</Typist>
<div className="TypistExample-content">
{this.state.renderMsg ? (
<Typist
className="TypistExample-message"
cursor={{ hideWhenDone: true }}
>
* Easy to style
<Typist.Delay ms={1250} />
<br />
* Easy to customize
<Typist.Delay ms={1250} />
<br />
* Easy to use backp
<Typist.Delay ms={500} />
sace
<Typist.Backspace count={5} delay={1000} />
<Typist.Delay ms={750} />
space
<Typist.Delay ms={1250} />
<br />
<span>
*{" "}
<a href={docs} className="flash">
docs
</a>
</span>
<br />
{""}
</Typist>
) : null}
</div>
</div>
);
}
}

View File

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

View File

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