From 426209370f7d2ce92cd9bd73d6a6a1d4bb94a592 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Wed, 18 Jul 2018 00:02:32 -0700 Subject: [PATCH] feat: Create Typescript definitions (#51) * [Typescript] Created Typescript definitions * Update index.d.ts --- index.d.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..111c548 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,28 @@ +import * as React from 'react'; + +export interface Dimensions { + top: number; + right: number; + bottom: number; + left: number; + width: number; + height: number; +} + +export interface ContainerDimensionsProps { + /** + * Can either be a function that's responsible for rendering children. + * This function should implement the following signature: + * ({ height, width }) => PropTypes.element + * Or a React element, with width and height injected into its props. + */ + children: ((props: Dimensions) => React.ReactNode) | React.ReactNode; +} + +/** + * Component that automatically adjusts the width and height of a single child. + * Child component should not be declared as a child but should rather be specified by a `ChildComponent` property. + * All other properties will be passed through to the child component. + */ +declare const ContainerDimensions: React.ComponentType; +export default ContainerDimensions;