diff --git a/types/clamp-js-main/clamp-js-main-tests.ts b/types/clamp-js-main/clamp-js-main-tests.ts new file mode 100644 index 0000000000..f903b82a06 --- /dev/null +++ b/types/clamp-js-main/clamp-js-main-tests.ts @@ -0,0 +1,22 @@ +import clamp, { ClampOptions, ClampResponse } from 'clamp-js-main'; + +const element: HTMLElement = document.createElement('div'); +element.style.setProperty('width', '5px'); +element.style.setProperty('height', '5px'); +element.style.setProperty('font-size', '12px'); + +const span: HTMLSpanElement = document.createElement('span'); +span.textContent = "Lorem ipsum. Lorem ipsum"; +element.appendChild(span); + +const simpleClamp: ClampResponse = clamp(element); + +const options: ClampOptions = { + clamp: 2, + useNativeClamp: false, + splitOnChars: ['.'], + animate: true, + truncationChar: '--', + truncationHTML: '' +}; +const clampWithOptions: ClampResponse = clamp(element, options); diff --git a/types/clamp-js-main/index.d.ts b/types/clamp-js-main/index.d.ts new file mode 100644 index 0000000000..75286172cb --- /dev/null +++ b/types/clamp-js-main/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for clamp-js-main 0.11 +// Project: https://github.com/jmenglis/clamp-js-main#readme +// Definitions by: Sinziana Nicolae +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface ClampOptions { + clamp?: number|string; + useNativeClamp?: boolean; + splitOnChars?: string[]; + animate?: boolean; + truncationChar?: string; + truncationHTML?: string | null; +} + +export interface ClampResponse { + original: string; + clamped: string; +} + +export default function clamp(element: HTMLElement, options?: ClampOptions): ClampResponse; diff --git a/types/clamp-js-main/tsconfig.json b/types/clamp-js-main/tsconfig.json new file mode 100644 index 0000000000..5c05321afc --- /dev/null +++ b/types/clamp-js-main/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "clamp-js-main-tests.ts" + ] +} diff --git a/types/clamp-js-main/tslint.json b/types/clamp-js-main/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/clamp-js-main/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }