diff --git a/types/react-stickynode/index.d.ts b/types/react-stickynode/index.d.ts new file mode 100644 index 0000000000..884b0390d9 --- /dev/null +++ b/types/react-stickynode/index.d.ts @@ -0,0 +1,79 @@ +// Type definitions for react-stickynode 1.4 +// Project: https://github.com/yahoo/react-stickynode +// Definitions by: Tim Stirrat +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from "react"; + +export = Sticky; + +/** A performant and comprehensive React sticky component. */ +declare class Sticky extends React.Component { + static defaultProps: Sticky.Props; + static STATUS_ORIGINAL: Sticky.StatusCode.STATUS_ORIGINAL; + static STATUS_RELEASED: Sticky.StatusCode.STATUS_RELEASED; + static STATUS_FIXED: Sticky.StatusCode.STATUS_FIXED; +} + +declare namespace Sticky { + enum StatusCode { + /** The default status, located at the original position. */ + STATUS_ORIGINAL = 0, + + /** + * The released status, located at somewhere on document, but not + * default one. + */ + STATUS_RELEASED = 1, + STATUS_FIXED = 2 + } + + interface Status { + status: StatusCode; + } + + interface Props { + /** The switch to enable or disable Sticky (true by default ). */ + enabled?: boolean; + + /** + * The offset from the top of window where the top of the element will + * be when sticky state is triggered(0 by default ).If it is a selector + * to a target(via `querySelector()`), the offset will be the height of + * the target. + */ + top?: number | string; + + /** + * The offset from the top of document which release state will be + * triggered when the bottom of the element reaches at.If it is a + * selector to a target(via `querySelector()`), the offset will be the + * bottom of the target. + */ + bottomBoundary?: number | string; + + /** z - index of the sticky */ + innerZ?: number | string; + + /** Enable the use of CSS3 transforms (true by default ). */ + enableTransforms?: boolean; + + /** + * Class name to be applied to the element when the sticky state is + * active (active by default ). + */ + activeClass?: string; + + /** + * Class name to be applied to the element when the sticky state is + * released (released by default ). + */ + releasedClass?: string; + + /** Callback for when the sticky state changes.See below. */ + onStateChange?: (status: Status) => void; + + shouldFreeze?: () => boolean; + } +} diff --git a/types/react-stickynode/react-stickynode-tests.tsx b/types/react-stickynode/react-stickynode-tests.tsx new file mode 100644 index 0000000000..5db49f63f0 --- /dev/null +++ b/types/react-stickynode/react-stickynode-tests.tsx @@ -0,0 +1,34 @@ +import * as Sticky from "react-stickynode"; +import * as React from "react"; + +const StickyAllOptions: JSX.Element = ( + s.status === Sticky.StatusCode.STATUS_ORIGINAL} + shouldFreeze={() => false} + > +
+ +); + +const StickyOptionalStringOptions: JSX.Element = ( + +
+ +); + +const StickyNoOptions: JSX.Element = ( + +
+ +); diff --git a/types/react-stickynode/tsconfig.json b/types/react-stickynode/tsconfig.json new file mode 100644 index 0000000000..0d36cc6d18 --- /dev/null +++ b/types/react-stickynode/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "jsx": "react", + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-stickynode-tests.tsx" + ] +} diff --git a/types/react-stickynode/tslint.json b/types/react-stickynode/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-stickynode/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }