diff --git a/types/bricks.js/bricks.js-tests.ts b/types/bricks.js/bricks.js-tests.ts new file mode 100644 index 0000000000..dbef221df0 --- /dev/null +++ b/types/bricks.js/bricks.js-tests.ts @@ -0,0 +1,18 @@ +import Bricks from 'bricks.js'; + +const bricks = Bricks({ + container: document.body.firstChild!, + packed: 'packed', + sizes: [ + { columns: 2, gutter: 10 }, + { mq: '768px', columns: 3, gutter: 25 }, + { mq: '1024px', columns: 4, gutter: 25 }, + ] +}); + +bricks + .pack() + .resize() + .on('resize', (detail) => { + const columns: number = detail.columns; + }); diff --git a/types/bricks.js/index.d.ts b/types/bricks.js/index.d.ts new file mode 100644 index 0000000000..1b4da86ebe --- /dev/null +++ b/types/bricks.js/index.d.ts @@ -0,0 +1,36 @@ +// Type definitions for bricks.js 1.8 +// Project: https://github.com/callmecavs/bricks.js +// Definitions by: Pusztai Tibor +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function BricksFactory(options: BricksOptions): BricksInstance; + +export interface BricksInstance { + pack(): BricksInstance; + update(): BricksInstance; + resize(flag?: boolean): BricksInstance; + + on(event: 'pack' | 'update', listener: () => any): BricksInstance; + on(event: 'resize', listener: (sizeDetail: SizeDetail) => any): BricksInstance; + + once(event: 'pack' | 'update', listener: () => any): BricksInstance; + once(event: 'resize', listener: (sizeDetail: SizeDetail) => any): BricksInstance; + + off(event: 'pack' | 'update', listener?: () => any): BricksInstance; + off(event: 'resize', listener?: (sizeDetail: SizeDetail) => any): BricksInstance; +} + +export interface BricksOptions { + container: Node | string; + packed: string; + sizes: SizeDetail[]; + position?: boolean; +} + +export interface SizeDetail { + mq?: string; + columns: number; + gutter: number; +} + +export default BricksFactory; diff --git a/types/bricks.js/tsconfig.json b/types/bricks.js/tsconfig.json new file mode 100644 index 0000000000..5a4746ea86 --- /dev/null +++ b/types/bricks.js/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bricks.js-tests.ts" + ] +} diff --git a/types/bricks.js/tslint.json b/types/bricks.js/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/bricks.js/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }