Merge pull request #22084 from sinziananicolae/add-clamp-js-main-types

Add clamp-js-main types
This commit is contained in:
Mine Starks
2017-12-11 09:57:26 -08:00
committed by GitHub
4 changed files with 67 additions and 0 deletions
@@ -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: '<span></span>'
};
const clampWithOptions: ClampResponse = clamp(element, options);
+20
View File
@@ -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 <https://github.com/sinziananicolae>
// 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;
+24
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }