add @types/react-stars (#40725)

This commit is contained in:
LittleB
2019-12-02 12:38:52 -08:00
committed by Andrew Casey
parent ce5ef64de9
commit c10ef267d3
4 changed files with 86 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
// Type definitions for react-stars 2.2
// Project: https://github.com/n49/react-stars
// Definitions by: TingYuLC <https://github.com/TingYuLC>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.6
import * as React from "react";
interface ReactStarsProps {
/** Name of parent class */
className?: string;
/** How many total stars you want */
count?: number;
/** Set rating value */
value?: number;
/** Which character you want to use as a star */
char?: string;
/** Color of inactive star (this supports any CSS valid value) */
color1?: string;
/** Color of selected or active star */
color2?: string;
/** Size of stars (in px) */
size?: number;
/** Should you be able to select rating or just see rating (for reusability) */
edit?: boolean;
/** Should component use half stars, if not the decimal part will be dropped otherwise normal algebra rools will apply to round to half stars */
half?: boolean;
/** Will be invoked any time the rating is changed */
onChange?: (new_rating: number) => void;
}
declare class ReactStars extends React.Component<ReactStarsProps> {}
export default ReactStars;
+17
View File
@@ -0,0 +1,17 @@
import ReactStars from "react-stars";
import * as React from "react";
const starsChange = (newVal: number) => {};
const Stars: JSX.Element = (
<ReactStars
count={5}
value={4.5}
color1="#E6E6E6"
color2="#FFCC33"
edit
half
size={14}
onChange={starsChange}
/>
);
+25
View File
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"esModuleInterop": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"jsx": "react",
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-stars-tests.tsx"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }