From 7f376606df1905ef486cfd6f252e41bfb969dcf1 Mon Sep 17 00:00:00 2001 From: Henri Normak Date: Tue, 11 Sep 2018 03:03:32 +0300 Subject: [PATCH] feat: add definitions for react-sparklines (#28640) --- types/react-sparklines/index.d.ts | 77 +++++++++++++++++++ .../react-sparklines-tests.tsx | 39 ++++++++++ types/react-sparklines/tsconfig.json | 24 ++++++ types/react-sparklines/tslint.json | 1 + 4 files changed, 141 insertions(+) create mode 100644 types/react-sparklines/index.d.ts create mode 100644 types/react-sparklines/react-sparklines-tests.tsx create mode 100644 types/react-sparklines/tsconfig.json create mode 100644 types/react-sparklines/tslint.json diff --git a/types/react-sparklines/index.d.ts b/types/react-sparklines/index.d.ts new file mode 100644 index 0000000000..bcc322eb90 --- /dev/null +++ b/types/react-sparklines/index.d.ts @@ -0,0 +1,77 @@ +// Type definitions for react-sparklines 1.7 +// Project: https://github.com/borisyankov/react-sparklines#readme +// Definitions by: Henri Normak +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +export interface Point { + x: number; + y: number; +} + +export interface SparklinesProps { + data?: number[]; + limit?: number; + width?: number; + height?: number; + svgWidth?: React.SVGAttributes['width']; + svgHeight?: React.SVGAttributes['height']; + preserveAspectRatio?: React.SVGAttributes['preserveAspectRatio']; + margin?: number; + min?: number; + max?: number; + style?: React.SVGAttributes['style']; +} +export class Sparklines extends React.PureComponent {} + +export interface SparklinesBarsProps { + points?: Point[]; + height?: number; + style?: React.SVGAttributes['style']; + barWidth?: number; + margin?: number; + onMouseMove?: (p: Point, event: React.MouseEvent) => void; +} +export class SparklinesBars extends React.Component {} + +export interface SparklinesCurveProps { + color?: React.SVGAttributes['color']; + style?: React.SVGAttributes['style']; +} +export class SparklinesCurve extends React.Component {} + +export interface SparklinesLineProps { + color?: React.SVGAttributes['color']; + style?: React.SVGAttributes['style']; + onMouseMove?: (event: 'enter' | 'click', value: number, point: Point) => void; +} +export class SparklinesLine extends React.Component {} + +export interface SparklinesNormalBandProps { + style?: React.SVGAttributes['style']; +} +export class SparklinesNormalBand extends React.Component {} + +export interface SparklinesReferenceLineProps { + type?: 'max' | 'min' | 'mean' | 'avg' | 'median' | 'custom'; + value?: number; + style?: React.SVGAttributes['style']; +} +export class SparklinesReferenceLine extends React.Component {} + +export interface SparklinesSpotsProps { + size?: number; + style?: React.SVGAttributes['style']; + spotColors?: { [change: string]: string }; +} +export class SparklinesSpots extends React.Component {} + +export interface SparklinesTextProps { + text?: string; + point?: Point; + fontSize?: number; + fontFamily?: string; +} +export class SparklinesText extends React.Component {} diff --git a/types/react-sparklines/react-sparklines-tests.tsx b/types/react-sparklines/react-sparklines-tests.tsx new file mode 100644 index 0000000000..4069cd9733 --- /dev/null +++ b/types/react-sparklines/react-sparklines-tests.tsx @@ -0,0 +1,39 @@ +import * as React from 'react'; +import { + Sparklines, + SparklinesLine, + SparklinesCurve, + SparklinesBars, + SparklinesReferenceLine, + SparklinesNormalBand, + SparklinesSpots, + SparklinesText, +} from 'react-sparklines'; + +class SparklinesDefaultTest extends React.Component { + render() { + return ( + + + + + + + + + + ); + } +} + +class SparklinesRegularTest extends React.Component { + render() { + return ( + + + + + + ); + } +} diff --git a/types/react-sparklines/tsconfig.json b/types/react-sparklines/tsconfig.json new file mode 100644 index 0000000000..a03ec22d0e --- /dev/null +++ b/types/react-sparklines/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "react-sparklines-tests.tsx" + ] +} diff --git a/types/react-sparklines/tslint.json b/types/react-sparklines/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-sparklines/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }