mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add document ready & linear-gradient (#27367)
* Add document-ready * Add linear-gradient
This commit is contained in:
parent
ed33c9ae20
commit
655e4406d0
4
types/document-ready/document-ready-tests.ts
Normal file
4
types/document-ready/document-ready-tests.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import ready = require("document-ready");
|
||||
ready(() => {
|
||||
// on load
|
||||
});
|
||||
7
types/document-ready/index.d.ts
vendored
Normal file
7
types/document-ready/index.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
// Type definitions for document-ready 2.0
|
||||
// Project: https://github.com/bendrucker/document-ready#readme
|
||||
// Definitions by: Jack Works <https://github.com/Jack-Works>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function ready(callback: () => void): void;
|
||||
export = ready;
|
||||
23
types/document-ready/tsconfig.json
Normal file
23
types/document-ready/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"strictFunctionTypes": true,
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"document-ready-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/document-ready/tslint.json
Normal file
1
types/document-ready/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
18
types/linear-gradient/index.d.ts
vendored
Normal file
18
types/linear-gradient/index.d.ts
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
// Type definitions for linear-gradient 1.0
|
||||
// Project: https://github.com/karmadata/linear-gradient#readme
|
||||
// Definitions by: Jack Works <https://github.com/Jack-Works>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
type Color = [number, number, number];
|
||||
declare class Gradient {
|
||||
constructor(colors: Color[]);
|
||||
/**
|
||||
* the input value should be normalized to the range between 0 and 1
|
||||
*/
|
||||
calcArray(normalizedPercent: number): Color;
|
||||
/**
|
||||
* the input value should be normalized to the range between 0 and 1
|
||||
*/
|
||||
calcHex(normalizedPrecent: number): string;
|
||||
}
|
||||
export = Gradient;
|
||||
23
types/linear-gradient/linear-gradient-tests.ts
Normal file
23
types/linear-gradient/linear-gradient-tests.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import Gradient = require("linear-gradient");
|
||||
|
||||
// instantiate with an RGB palette
|
||||
const grad1 = new Gradient([
|
||||
[0, 0, 0],
|
||||
[0, 80, 0],
|
||||
[0, 160, 80],
|
||||
[80, 80, 80],
|
||||
[160, 40, 40],
|
||||
[255, 0, 0]
|
||||
]);
|
||||
|
||||
// now we are ready to calculate the colors
|
||||
// the input value should be normalized to the range between 0 and 1
|
||||
|
||||
(grad1.calcArray(0)); // -> [0,0,0] (0 -> first color of the palette)
|
||||
(grad1.calcArray(1)); // -> [255,0,0] (1 -> last color of the palette)
|
||||
(grad1.calcArray(0.25)); // -> [0,100,20] (weighted average between [0,80,0] and [0,160,80])
|
||||
(grad1.calcArray(0.5));
|
||||
(grad1.calcArray(0.75));
|
||||
|
||||
(grad1.calcHex(1)); // -> '#ffffff'
|
||||
(grad1.calcHex(0.25)); // -> '#006416'
|
||||
24
types/linear-gradient/tsconfig.json
Normal file
24
types/linear-gradient/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"strictFunctionTypes": true,
|
||||
"esModuleInterop": true,
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"linear-gradient-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/linear-gradient/tslint.json
Normal file
1
types/linear-gradient/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user