Add Types for react-countdown-circle-timer 1.0.3 (#40724)

* Add Types for react-countdown-circle-timer 1.0.3

* Fixed Definition

* Fixed Test
This commit is contained in:
Tim Ittermann 2019-12-02 21:37:28 +01:00 committed by Andrew Casey
parent f1e572c94d
commit ce5ef64de9
4 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,28 @@
// Type definitions for react-countdown-circle-timer 1.0
// Project: https://github.com/vydimitrov/react-countdown-circle-timer
// Definitions by: Tim Ittermann <https://github.com/timia2109>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.6
import { Component, ReactNode } from 'react';
export type ColorType = ReadonlyArray<[ string, number? ]>;
export type StrokeLinecapType = "round" | "square";
export type RenderTimeFunctionType = (remainingTime: number, elapsedTime: number, isPlaying: boolean) => ReactNode;
export type OnCompleteFunctionType = () => [boolean, number] | undefined | void;
export class CountdownCircleTimer extends Component<Props> {}
export interface Props {
durationSeconds: number;
colors: ColorType;
size?: number;
strokeWidth?: number;
strokeLinecap?: StrokeLinecapType;
trailColor?: string;
isPlaying?: boolean;
isLinearGradient?: boolean;
gradientUniqueKey?: string;
renderTime?: RenderTimeFunctionType;
onComplete?: OnCompleteFunctionType;
}

View File

@ -0,0 +1,22 @@
import * as React from "react";
import { CountdownCircleTimer } from "react-countdown-circle-timer";
const Test: React.FC = () => {
return <CountdownCircleTimer
isPlaying
durationSeconds={10}
colors={[
['#004777', .33],
['#F7B801', .33],
['#A30000']
]}
size={200}
strokeWidth={5}
strokeLinecap="round"
trailColor="#3f3f3f"
isLinearGradient
gradientUniqueKey="myKey"
renderTime={(r, e, p) => <h1>Test</h1>}
onComplete={() => { }}
/>;
};

View File

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

View File

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