diff --git a/types/reactcss/index.d.ts b/types/reactcss/index.d.ts index 2d571674f7..fe64ed4ce9 100644 --- a/types/reactcss/index.d.ts +++ b/types/reactcss/index.d.ts @@ -1,29 +1,29 @@ -// Type definitions for ReactCSS v1.0.0 +// Type definitions for ReactCSS 1.2.0 // Project: http://reactcss.com/ -// Definitions by: Karol Janyst +// Definitions by: Chris Gervang , Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.2 import * as React from "react" - -interface LoopableProps { +interface LoopableProps extends React.Props { + "nth-child": number "first-child"?: boolean "last-child"?: boolean even?: boolean odd?: boolean - [nthChild: string]: boolean } -interface HoverProps { +interface HoverProps extends React.Props { hover?: boolean } -interface Classes { - default: any - [scope: string]: any +interface Classes { + default: Partial + [scope: string]: Partial } +export type CSS = React.CSSProperties export function hover(component: React.ComponentClass | React.StatelessComponent): React.ComponentClass -export function loop(i: number, length: number): LoopableProps -export default function reactCSS(classes: Classes, ...activations: Array): any +export function loop(index: number, length: number): LoopableProps +export default function reactCSS(classes: Classes, ...activations: Array): T diff --git a/types/reactcss/reactcss-tests.tsx b/types/reactcss/reactcss-tests.tsx index 058958c7bf..0ba1f69fc2 100644 --- a/types/reactcss/reactcss-tests.tsx +++ b/types/reactcss/reactcss-tests.tsx @@ -1,19 +1,67 @@ import * as React from "react" -import { StatelessComponent } from "react" +import { SFC } from "react" import { render } from "react-dom" -import { default as reactCSS, hover, loop, LoopableProps, HoverProps } from "reactcss" +import { default as reactCSS, hover, loop, LoopableProps, HoverProps, CSS } from "reactcss" -interface TestProps extends HoverProps { } +interface TestHoverProps extends HoverProps { } -var styles: any = reactCSS({ - default: {}, - hover: {} -}, { hover: true }) +const TestHover: SFC = ({hover}) => { + const styles = reactCSS<{title: CSS}>({ + default: { + title: { + color: "black" + } + }, + hover: { + title: { + color: "blue" + } + } + }, { hover }) -var loopProps: LoopableProps = loop(1, 10) + const list = ["First!", "Second!", "Third!"] -var TestComponent: StatelessComponent -var Test = hover(TestComponent) + return ( +
+
+ Cool Title! +
+ + {list.map((item, index) => ( + {item} + ))} +
+ ) +} + +interface TestLoopProps extends LoopableProps { } + +const TestLoop: SFC = (props) => { + const styles = reactCSS<{element: CSS}>({ + default: { + element: { + width: "200px", + border: "1px solid black" + } + }, + "first-child": { + element: { + borderTopLeftRadius: "2px", + borderTopRightRadius: "2px" + } + }, + "last-child": { + element: { + borderBottomLeftRadius: "2px", + borderBottomRightRadius: "2px" + } + } + }, props) + + return
{props.children}
+} + +const Test = hover(TestHover) render( ,