Merge pull request #24546 from VitorLuizC/feature/add-is-color-definition

Add definition for is-color
This commit is contained in:
Nathan Shively-Sanders
2018-03-27 08:57:14 -07:00
committed by GitHub
4 changed files with 67 additions and 0 deletions

20
types/is-color/index.d.ts vendored Normal file
View File

@@ -0,0 +1,20 @@
// Type definitions for is-color 1.0
// Project: https://github.com/morishitter/is-color
// Definitions by: Vitor Luiz Cavalcanti <https://github.com/VitorLuizC>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function isColor(str: string): boolean;
declare namespace isColor {
function isRgb(str: string): boolean;
function isRgba(str: string): boolean;
function isHsl(str: string): boolean;
function isHsla(str: string): boolean;
function isHex(str: string): boolean;
function isKeyword(str: string): boolean;
function isInherit(str: string): str is 'inherit';
function isCurrentColor(str: string): str is ('currentColor' | 'currentcolor');
function isTransparent(str: string): str is 'transparent';
}
export = isColor;

View File

@@ -0,0 +1,23 @@
import isColor = require('is-color');
isColor('#000');
// => boolean
isColor.isHex('#000');
// => boolean
isColor.isHsl('#000');
// => boolean
isColor.isHsla('#000');
// => boolean
isColor.isRgb('rgb(0, 0, 0)');
// => boolean
isColor.isRgba('rgba(0,0,0, 0)');
// => boolean
isColor.isKeyword('red');
// => boolean
isColor.isInherit('inherit');
// => is 'inherit'
isColor.isTransparent('transparent');
// => is 'transparent'
isColor.isCurrentColor('currentColor');
// => is 'currentColor'|'currentcolor'

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"is-color-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }